- Home /
Use frame time for physics update: is it ok?
Since physics uses FixedUpdate, it may not update, or update many times in a single frame, which makes my scripts a mess, especially communicating between Update
and FixedUpdate
.
Since there's Physics2D.Simulate()
Method, I'm simply using render update event to feed it:
void Update() {
...
Physics2D.Simulate(Time.deltaTime);
...
}
My question is: Since Unity originally does not update in this way, what's the disadvantage? Is it "really" bad so that we should always avoid update like this?
Using FixedUpdate alongside Update isn't that difficult. If you're having trouble with it, it'd be a much better use of your time to work that out, rather than trying to patch over your problems with a hack like this. And helping you with that would be a better use of our time too. So my recommendation would be to post a new question about your messy scripts. Chances are there's something fairly simple about how things work, that you're not getting.
Answer by xxmariofer · Aug 01, 2019 at 12:27 PM
Calculating physics will never be 100% precise, but passing a value that is changing all the time will make it even more un precise. Here is what unity saiys about using tim.deltatime with simulate
Note that if you pass framerate-dependent step values (such as Time.deltaTime) to the physics engine, your simulation will be non-deterministic because of the unpredictable fluctuations in framerate that can arise.
Your answer
Follow this Question
Related Questions
Rigidbody2d.MovePosition on Update vs FixedUpdate 1 Answer
How often does the internal physics calculation get called? 1 Answer
Could Update and FixedUpdate happen at the same time? 1 Answer
Should we check animation condition in Update or FixedUpdatE? 3 Answers
Problem with Fixed Timestep 0 Answers