- Home /
Rigidbody2d.MovePosition on Update vs FixedUpdate
Hi! I know it's been discussed a lot of times already, and every single documentation tells that I should perform any action with Rigidbody on FixedUpdate. However, I just checked "2D Roguelike" tutorial by Unity, and now I'm confused. They are calling MovePosition in coroutine (it's the same as on Update) with Time.deltaTime. I run it by myself, and It works super fine (I don't see any cons at least in Editor), and the code looks much cleaner with this approach. Link for the tutorial
So, the question is: after all, what's the correct approach to manipulate with Rigidbody? Is there any real difference between them? Maybe some performance or precise stuff, I don't know...
just read this and it's actually all you need to know, so no need for me to explain it:
https://docs.unity3d.com/ScriptReference/Rigidbody2D.$$anonymous$$ovePosition.html
Physics is run on the fixed update loop, so changes made during update, won't actually be physically calculated until the next fixed update. All physics interactions should be ran on the Fixed Update loop.
Which is what I assume @hexagonius was wanting you to read. Also, you should still give it a read.
@hexagonius @RobAnthem Guys, of course I've red this documentation. If it's the only valid way to do it, then why Unity shows invalid way (i.e calling $$anonymous$$ovePosition in coroutine and multiplying it by Time.deltaTime) in their official tutorial? Is it just a bug?
Answer by hexagonius · Mar 24, 2018 at 07:55 AM
because it is allowed and deferred to FixedUpdate, BUT because of that only the last call you make during Update will be executed then.
It's legit, but not recommended.
Your answer
Follow this Question
Related Questions
How often does the internal physics calculation get called? 1 Answer
rigidbody2D.MovePosition() Can't Found 2 Answers
Checkibg Rigidbody2d and component problems 0 Answers
How do I convert this into Fixed Update for physics and Update for inputs? 0 Answers
Can the Script Execution order be adjusted for FixedUpdate()? 3 Answers