Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by underdog1515 · Mar 23, 2018 at 09:29 PM · rigidbody2dupdatephysics2dfixedupdatemoveposition

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...

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Mar 23, 2018 at 09:37 PM 0
Share

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

avatar image RobAnthem · Mar 23, 2018 at 09:58 PM 0
Share

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.

avatar image underdog1515 · Mar 24, 2018 at 07:44 AM 0
Share

@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?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image underdog1515 · Mar 24, 2018 at 08:32 AM 0
Share

Okay, I'm fine with that explanation. Thank You!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

80 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges