Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Physics.Simulate ignores joints????

Discussion in 'Physics' started by MrPoggle, Oct 14, 2022.

  1. MrPoggle

    MrPoggle

    Joined:
    Oct 29, 2020
    Posts:
    5
    I am trying to use Physics.Simulate to see where a ball on a rope will end up. The ball is connected to a chain of several joints and in real time it looks great. But when I call physics.simulate, the ball just drops like a rock every time. How do I include the joint forces into the physics simulation???
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    No. It's the same call that Unity calls when it's called automatically; not a special code-path for you.

    You're doing something wrong here if that's happening. Might be that you're just passing in a huge time expecting it to somehow integrate that time which won't work. No idea.
     
  3. MrPoggle

    MrPoggle

    Joined:
    Oct 29, 2020
    Posts:
    5

    I have tried very small amounts of time like .1 seconds. The joints are never taken into account during the simulation. The links and ball all start falling straight down and hit the floor. Then turning normal simulation back on they go crazy and snap back to where they where as the joints pull everything back together
     
  4. MrPoggle

    MrPoggle

    Joined:
    Oct 29, 2020
    Posts:
    5

    Extra info: This is a 3d scene, not a 2d scene
     
  5. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,434
    That's a ver large time. By default Unity calls Physics.Simulate 50 times per second with time = 0.02 seconds.

    Edit: note that each call to Physics.Simulate simulates 1 "tick" of the physics. So in order to execute the physics simulation you must call it multiple times each second, as described above. Maybe you're just calling Physics.Simulate once, or too few times? Try calling Physics.Simulate(0.02f) from FixedUpdate.
     
    MelvMay likes this.
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    As above, you're doing joint simulation at 1/0.1 = 10Hz which is a very low frequency or in other words, to physics, large steps of time. 0.1 sec is a small amount of time to you but for physics calculations, it's at least 5x too much.

    The default Unity time-step is 50Hz (1/50), see Fixed Timestep in the Time Manager.

    This wouldn't make a difference. 2D physics wouldn't like this either. :)