Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 nhono99 · May 22, 2018 at 03:39 PM · physicsrigidbodyframeraterigidbody.velocityframerate drops

Is rigibody velocity frame rate independent?

I have this problem when I'm testing on the editor the the profiler physics have a frame rate of 1000 which is fast so the rigidbody is fast as well but when I tried it on a mobile device the rigidbody quite slow down. So setting rigidbody velocity via user input is bad? Because I couldn't put it on a FixedUpdate since it must trigger on user input.

Comment
Add comment · Show 2
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 misher · May 22, 2018 at 03:51 PM 0
Share

You CAN manage user's input in Update() and change rigidbody in FIxedUpdate(), or you can manipulate rigidbody in Update() (unrecomended) but use Time.deltaTime as a coeficiant to make it framerate independant.

avatar image nhono99 misher · May 23, 2018 at 01:50 AM 0
Share

I couldn't manipulate rigibody in FixedUpdate because I'am manipulating the rigidbody velocity once the user made an input. The is this. void Jump(){ rb.velocity = new Vector3(Random.Range(-1,1), 1, 0).normalized * power); rb.angularVelocity = Vector3.zero; }

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by FlaSh-G · May 28, 2018 at 01:45 PM

Your physics shouldn't have 1000 fps, but something around 50, meaning a fixed timestep of 0.02. That's the default value and changing it shouldn't happen without a good reason.

Now, Rigidbody.velocity is just some value that you can change. Nothing really happens when you change it. But when, in the next fixed update step, the physics engine does its work, it will move the all rigidbodies according to their velocities. Since it does that in a pseudo-constant frequency, changing fps should definitely have any influence on physics calculations. And chaning the velocity, at what time whatsoever, can't influence that.

As @misher said, you can watch input wherever you want and still apply it in FixedUpdate. You just need a variable that serves as a flag:

 private bool jumped;

 private void FixedUpdate()
 {
   if(jumped)
   {
     Jump();
     jumped = false;
   }
 }

However, as I explained, the velocity property already serves as this... "container" for changes to be applied in the next physics update.


So, as to why your velocity varies on mobile... do you use Time.deltaTime somewhere? What other code influenced time, phyiscs in general, or this rigidbody?

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

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

162 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 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 avatar image avatar image

Related Questions

Setting a RigidBody's velocity messes with my custom gravity, not sure how to proceed. 0 Answers

Cannot move and jump with rigid body. 0 Answers

Any way to gracefully detach object with Unity physics? 2 Answers

Rigbody.velocity stopped working and only displays 0 out of nowhere 2 Answers

Moving rigidbody (Player) with addForce or Velocity ? 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