Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
1
Question by arasem · Jun 28, 2016 at 12:53 PM · unity5time.deltatime

Time.deltaTime is "frozen" when game object is disabled

Hello

I noticed that if gameobject is disabled (setActive(false)) , then time delta seems to freeze. Basically it returns the time since the last frame is displayed and when the gameobject has entered the disabled mode. Whether I enable the object 1 sec or 10 seconds later, it is the same value returned.

Any idea why or how to get around that?

My use case is I am basically I am using the time delta to move the object and it seems to resume from when it was disabled and not (say 10 steps later)

Thank you

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 LMan · Jun 28, 2016 at 01:11 PM 0
Share

deltaTime is a static member of the Time class- it can't be different for each gameObject, since there is only 1 instance of it at any time. deltaTime is the time it took for the last frame of the game to complete.

If I understand what you are trying to do, you might try running your script on an empty that never gets disabled, and have a separate gameObject for the visual part that follows the empty and does get disabled. That way when you enable the visual it will pick up wherever the empty is at that point.

avatar image saschandroid · Jun 28, 2016 at 01:16 PM 0
Share

I guess you use Time.deltaTime in the Update() function of the script attached to the gameobject. When you disable it "Any scripts that you have attached to the GameObject will no longer have Update() called, for example." You probably want to just disable the $$anonymous$$eshRenderer component of the gameobject (GetComponent().enabled = false;)

2 Replies

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

Answer by hyperi0n · Jun 28, 2016 at 01:12 PM

I suppose the easiest way would be to create your own "deltaTime": At the end of a frame set

 myDeltaTime =  Time.time - lastUpdate;
 lastUpdate = Time.time;

and then use this "fake" deltaTime in the places where you need to use this tracked "time-since-last-update-even-if-the-object-was-disabled". Would this work for you?

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 arasem · Jun 28, 2016 at 07:11 PM 0
Share

Thank you. That makes sense for sure

avatar image
1

Answer by Xepherys · Jun 28, 2016 at 06:15 PM

You can always use Time.realtimeSinceStartup instead - maybe at least when activating and deactivating an object? Or at least when reactivating an object, you could use it to find the time elapsed since disabling it with an appropriately set variable.

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 arasem · Jun 28, 2016 at 07:13 PM 2
Share

Thanks for the idea. I wanted to stick to delta time but your idea would work as well

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity coroutine movement over time is not consistent/accurate? 1 Answer

how to simulate a hand using IMUs ? 0 Answers

[UNET] Problems with syncing Weapon rotation 0 Answers

Problem with figures 3d,Mistake with figures 3d 1 Answer

The error : No overload for method 'Clamps' takes 1 argument. 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