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
0
Question by AndreasX12 · Apr 01, 2013 at 08:40 AM · rigidbodytimespeeddeltatimeconstant

Time.deltaTime problems?

Hello, I can understand that the Time.deltaTime is very important when moving something at a constant speed (in this case, a rigidbody), but I can't get it to work.

With this code it work's good, but I guess it won't work well on slower computers.

     public int speed = 100;
     
     void FixedUpdate () {
         rigidbody.AddForce(transform.forward * speed);
     }

But with the Time.deltaTime it only moves very very slowly (barely noticeable) and it doesn't work to set a higher speed value. (It doesn't show any error's in the Console)

     public int speed = 100;
     
     void FixedUpdate () {
         rigidbody.AddForce(transform.forward * speed * Time.deltaTime);
     }

Can you understand what the error is here? :-)

Thanks, Andreas :-)

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 Fattie · Apr 01, 2013 at 09:02 AM 1
Share

actually I believe your first code example is totally, perfectly correct.

you're simply adding a fixed amount of force units (like "18" or something) at regular times. That's fine and you have no problems.

it will work identically on all computers because it is indeed running at a fixed rate.

regarding "Time.deltaTime" you basically use that when moving something .. so, you are moving it "by hand" using .Translate or just changing the .position

You could take a simple cube and experiment with moving it by Time.deltaTime, each Update() .. you'll see it moves smoothly.

1 Reply

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

Answer by Nidre · Apr 01, 2013 at 10:07 AM

This " rigidbody.AddForce(transform.forward speed);" adds 100 x of forward every frame so when you have 60 fixed frame per second it would mean 60 100 units of force.

But when you do this "rigidbody.AddForce(transform.forward speed Time.deltaTime);" it adds 100 units of force in 1 second.

So to compare First example adds 60.000 in 1 second. And the second example add 100 in 1 second.

İf you want to achieve the same speed like first example try setting the speed value to soemthing around 60.000.

That would work similiarly.

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 AndreasX12 · Apr 01, 2013 at 10:54 AM 0
Share

Thanks, the speed doesn't change at all even with the speed set to 60.00, I guess that I'll stick with Fattie's answer :-)

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

12 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

Related Questions

Player acts differently if not selected in the inspector 6 Answers

When I use rigidbody.Moveposition, the object doesn't move accurately. 1 Answer

Increase time for rigidbody game objects? 1 Answer

speed change in standalone compared to editor? 1 Answer

Rigidbody gain speed falling on slope 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