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 Smike · Aug 07, 2013 at 05:42 PM · timeframeratedeltatime

Using Time.DeltaTime doesn't result in framerate independence

I'm trying to lerp some items across a certain specified distance over a determined amount of time. I'm using Time.DeltaTime to achieve framerate independence. However, when forcing lag with the help of a very performance intensive function (drops the framerate to a theoretical 10-15fps), my objects move MUCH slower than they should, even though they should move in constant time, independent of framerate (they take about twice as long, 4s instead of 2s).

What's even stranger is that the calculated FPS (1.0f/Time.deltaTime) stays constant (approx. 66 FPS). When I show the time it took for the lerp to finish (adding up the time.deltaTimes), it shows 2 seconds (which is the desired time, however the actual time it took is at least 2x that).

Can anyone help me figure out what's going on?

var startTime = 0.0;

  while(startTime < 2.0){
      yield;
      startTime += Time.deltaTime;
      transform.localPosition = Vector3.Lerp(Vector3(0.0,0.0,0.0), Vector3(0.0,10.0,0.0), startTime/2.0);
  }
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 creighcl · Aug 07, 2013 at 05:54 PM 1
Share

Can you provide what that LERP call looks like?

avatar image perchik · Aug 07, 2013 at 06:03 PM 0
Share

Can you put in some debug.log statements into that while loop and show us the result?

 while(startTime < 2.0){
     Debug.Log("pre-yield, start time is" + startTime);
     yield; 
     Debug.Log("after yield, start time is + startTime);
     Debug.Log("deltatime is "+Time.deltaTime);
     startTime += Time.deltaTime;
     Debug.Log("startTime is now " + startTime);
     transform.localPosition = Vector3.Lerp(Vector3(0.0,0.0,0.0), Vector3(0.0,10.0,0.0), startTime/2.0);
 }

Also, I'm not entirely sure what you're trying to do by having the while loop yield and lerp in the while loop. Can you explain what you want/expect to happen?

1 Reply

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

Answer by Smike · Aug 07, 2013 at 06:05 PM

Ok, it's fixed. Apparently, the Maximum Allowed Timestep was modified. To fix it, I just went to Edit > Project Settings > Time, and then changed the Maximum Allowed Timestep to a high number (in my case: 0.5).

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

16 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

Related Questions

I can't get framerate independence to work... 1 Answer

Framerate Independent Firing Rate (delta time?) 2 Answers

deltaTime doesn't work with custom gravity (ECS) 0 Answers

Unity3d School 1 Answer

Is it a bad practice to change the timescale for the whole game? 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