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 steddyman · Mar 08, 2013 at 08:08 PM · movementupdatetimedeltatime

Movement using Time.deltaTime not working on Fast mac

I have a game that I have released for iOS, and on all iOS platforms the player moves up the screen at the same speed. It also moves up the same speed in the Editor.

However, I have now changed the project type to OSX and I am finding that when the app is compiled and launched on the desktop it is moving much slower. Also, if something slows down my Mac (for example notifications arriving) then it briefly speeds up.

I am moving the player in the following way, inside an Update function:

 transform.Translate(Vector3.up * Time.deltaTime * thrust, transform);

Isn't that the right way to get a constant speed by multiplying by Time.deltaTime?

On iOS and OSX the thrust value is 55.0. On the Editor the Time.deltaTime is usually around 0.004 but on the built player it is usually 0.002. On iOS it is usually around 0.03.

PS This is an 8 core 2008 Mac Pro with a fast Nvidia GTX 670 card.

What am I doing wrong?

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 steddyman · Mar 09, 2013 at 04:31 PM 0
Share

Anyone? Surely this is as basic as it can be. Why isn't multiplying by Time.deltaTime giving me a constant speed?

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by GabrielSmith · Mar 10, 2013 at 03:07 AM

I've had a problem like this before and the solution I used is in fact pretty simple. All you gotta do is to put the Time.deltaTime part on the FixedUpdate(), instead of Update(). Doing something like the following should solve your problem:

 Vector3 speed;
         
     void FixedUpdate () { 
     speed = Vector3.up * Time.deltaTime * thrust;
     }
         
     void Update () {
     transform.Translate(speed, transform);
     }

Hope this fixes your problem. :)

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 steddyman · Mar 10, 2013 at 11:46 AM 0
Share

That shouldn't make any difference. The Time.deltaStime will still be 0.002 inside the FixedUpdate function, then will be being applied at the same rate inside Update.

You could ins$$anonymous$$d update the speed by Time.fixedDeltaTime but then that would also have to be applied inside FixedUpdate to the transform otherwise it would definitely vary the speed on different systems.

$$anonymous$$ight be worth me sending a support request to Unity. Last time I sent them a bug report I never heard anything back.

avatar image
0

Answer by Loius · Mar 09, 2013 at 05:05 PM

Sounds like your Mac is having issues running the game. Time.deltaTime always results in correct time increments unless there's a catastrophic failure.

.002 is great, and your thrust is the same on both systems. Does -everything- move slowly? Did you change timescale?

Comment
Add comment · Show 4 · 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 fafase · Mar 09, 2013 at 05:26 PM 0
Share
 .002 is great

No, this is awesome!!!! Almost or surely unreal!!!! That means 500fps. $$anonymous$$ore likely 0.02

avatar image steddyman · Mar 09, 2013 at 09:09 PM 0
Share

Thanks. No I haven't changed the Timescale (1) or Gravity (default). All I am doing is changing the platform type.

On my iPad $$anonymous$$i the deltaTime is 0.03.

On my $$anonymous$$ac it is 0.002 in Forward rendering mode, and 0.004 in Deferred rendering mode.

Perhaps it is that high performance that is causing me issues. Perhaps there is a bug in Unity on really fast systems.

BTW This is a 8 core Xeon $$anonymous$$ac Pro (2008) with an Nvidia GTX 670, so it is very fast in $$anonymous$$ac performance terms.

Yes, it moves at less than half the normal speed, unless a notification comes in ($$anonymous$$ountain Lion) then it briefly speeds up.

avatar image steddyman · Mar 09, 2013 at 09:54 PM 0
Share

Just tried the same compiled binary on my $$anonymous$$acbook Air (2011) and it runs at full speed with no issues.

Definitely seems to be down to the speed of the $$anonymous$$ac Pro. I'll log a bug report.

avatar image Loius · Mar 10, 2013 at 12:13 AM 0
Share

Not often that I hear of a problem from a system being too AWESO$$anonymous$$E to run the software! Usually it's the opposite problem.

avatar image
0

Answer by UnityDev291 · Jun 20, 2019 at 11:11 AM

I've just recently hit this problem when running Unity 2019.1.1f1 with a 2018 MacBook Pro. So in case anyone else stumbles across this issue, this may help. I found the Time.deltaTime returned by the runtime Mac build was almost 10 times faster than the Unity Editor. When I forced the Application.targetFrameRate = 60; both the UnityEditor and the runtime build became consistent. Possibly the Unity Editor targetFrameRate is capped on Mac platforms? Note, I haven't seen this issue on a PC platform running Windows 10.

See also https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html

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

14 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

Related Questions

Movement lag, jitery every few seconds 1 Answer

Choppy movment for even the most basic stuff 2 Answers

Execute code every x seconds with Update() 4 Answers

Single Step (pause, resume), or externally clock game loop 0 Answers

Time.deltaTime not consistent over time 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