Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
0
Question by gdbjohnson · Jul 21, 2015 at 04:10 AM · physics2daddforcetranslate

RigidBody2D Performance with AddForce on WakeUp

I recently explored using RigidBody2D.AddForce to move my sprites around on the screen, instead of translating the gameobjects directly in FixedUpdate.

When the user pauses my game, I was saving the velocity of the RigidBody2D and then setting IsKinematic to true.
When the user resumes the game, I would re-apply the Force and wake up the RigidBody2D object.

I noticed that when the user resumes, there is a delay before the objects starts moving again, and it is a small delay and it is intermittent, but very noticeable. Does it take Unity a few cycles before it is able to process all the wakeup's across all the objects? Switching back to my transform.Translate() method, there is no delay when the game resumes.

Is Physics2D expensive computationally?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MelvMay · Jul 21, 2015 at 08:11 AM

Not sure what you mean by wakeup's here, you mean wake the rigid-body?

If nothing is happening then wouldn't you be better off taking all the rigid-body out of the simulation by using: http://docs.unity3d.com/ScriptReference/Rigidbody2D-simulated.html

If not that, then store the velocity and reapply that when you unpause.


As nearly all physics changes, any change made is dealt with during the next fixed-update and subsequent fixed-updates.

Some changes such as changing the body type happen instantly in that any existing contacts are clear but new ones are not recalculated until the next fixed update thus you won't get any callbacks until then.

Asking is Physics2D is expensive computationally is pretty vague, maybe you can be more specific there but henerally it's very cheap; the dominant computational costs typically rise as the number of contacts between colliders rise as well as using continuous collision-detection on dynamic rigid-bodies. Moving dynamic bodies directly yourself can be expensive as contacts have to be continually recalculated (don't do it).

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 gdbjohnson · Jul 21, 2015 at 07:42 PM 0
Share

ya, I was putting the RigidBody to sleep essentially, which I realize now is a terrible idea. It turns out that setting the object InActive was enough. With Unity there are so many ways of achieving the same result. Thanks for the info on "simulated". I'll keep that one in $$anonymous$$d as well.

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

23 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

Related Questions

AddForce applies different amount on Android than PC 0 Answers

AddForce not moving object after instantiate 1 Answer

The character velocity changes while the rigidbody is kinematic 1 Answer

how should i move a vehicle correctly in unity,what kind of rigidbody physics should i add to move a vehicle ?? 1 Answer

Move Physics2D Object With Mouse Using AddForce? 0 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