Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 ronronmx · Nov 19, 2012 at 10:06 PM · physics

How to keep physics consistent?

To start of, my game is pretty physics heavy, as it's a racing game with high speed moving vehicles. Also, it runs on iPhone/Android, so I have to find a good compromise.

My first question is regarding the "Fixed Timestep" and "Maximum Allowed Timestep" settings. My current settings are as follow:

Fixed Timestep: 0.02 Max Allowed: 0.1

I can get away with 0.03 but sometimes, the wheel colliders go through the ground, so I have to add Sphere Colliders to my wheels as well to keep them from doing it. I went back down to 0.02 because my frame-rate is still over 45-55 even at that value, so I might as well have better physics simulations if I can afford it. I was wondering, for you guys that are developing physics heavy games on mobile devices, what settings seem to work best for you?

My second question is about physics calculations in FixedUpdate. I have been developing my game, for the most part, at a Fixed Timestep of 0.03, and now that I lowered it to 0.02, my physics calculation are "stronger"...for example, I have a "Spring" function that basically does this in Fixed Update:

springPower = 5000f;
transform.rigidbody.AddRelativeForce( ForceDir * springPower, ForceMode.Impulse );

With a Timestep of 0.02, that force is stronger and pushes my vehicle higher into the sky then with a Timestep of 0.03, which is normal behavior correct? How can I force that calculation to always apply the same amount of force regardless of the Timestep value?

That's it, thanks for your time guys!

Stephane

Comment
Add comment · Show 1
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 sparkzbarca · Nov 19, 2012 at 10:16 PM 0
Share

there is no way short of running it in update maybe and using time.deltatime.

1 Reply

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

Answer by ThePunisher · Nov 20, 2012 at 12:30 AM

Can't you multiply by the Time.fixedDeltaTime so that only a certain amount of that force is applied based on the delta. So a larger delta between time steps applies more force per step and a smaller time step applies less. Does that make sense or did I just lose my mind? Sorry I'm distracted right now :(

Comment
Add comment · Show 5 · 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 ronronmx · Nov 21, 2012 at 02:37 AM 0
Share

Well I thought about doing that but wasn't sure if it was the right thing to do...shouldn't I multiply by Time.deltaTime ins$$anonymous$$d, even in Fixedupdate?

I tried it, and even with a really high multiplier, the forces applied were super weak using Force$$anonymous$$ode.Inpulse (which I have been using all this time), but with Force$$anonymous$$ode.VelocityChange, the forces applied were strong enough again - same high multiplier - which is why I said that I am not sure this is the right way to do it, since it seams that all the other Force$$anonymous$$ode don't work correctly when multiplying by fixedDeltaTime or deltaTime...maybe I am doing something wrong?

avatar image ThePunisher · Nov 21, 2012 at 06:10 PM 0
Share

Well the reason you are seeing what you are seeing is because one instantly changes the velocity ignoring the mass of the object (meaning the property "mass" of your rigid body) while the other takes it into account.

So, if your object's mass is large then it would make sense that Force$$anonymous$$ode.Impulse would be weaker.

Force$$anonymous$$ode.VelocityChange: http://docs.unity3d.com/Documentation/ScriptReference/Force$$anonymous$$ode.VelocityChange.html

Force$$anonymous$$ode.Impulse: http://docs.unity3d.com/Documentation/ScriptReference/Force$$anonymous$$ode.Impulse.html

avatar image ronronmx · Nov 21, 2012 at 10:59 PM 0
Share

Ah thx, I did not know about this :) But, when I was doing my testing, I raised the force being applied to my rigidbody (whit Impulse) to a ridiculously high number like 5000000, and it barely made a difference. When I don't multiply that by deltaTime or fixedDelatTime in FixedUpdate, then the forces being applied work as they should (I need like 10 times more forces when using Impulse then I do when using VelocityChange).

I'll try again and see if maybe I was doing something wrong...

avatar image ronronmx · Nov 22, 2012 at 08:13 PM 0
Share

So yeah I was doing something wrong, works as expected now, thanks guys!

avatar image ThePunisher · Nov 26, 2012 at 06:59 PM 0
Share

No worries man, glad you got it figured out.

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

11 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Physics: Is it possible to count the number of colliders hit with OverlapSphere? 1 Answer

Make car CenterOfMass change dynamically 1 Answer

If statment to check if player is within collider 1 Answer

Parenting player to car on click. 1 Answer


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