Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 macsimilian · Jan 02 at 12:05 AM · timetime.deltatimetimescaledeltatimetime.timescale

2nd independent deltaTime and timeScale variables, or a way to mimic this?

I need another deltaTime system, since I have objects that I need to slow up / slow down independently using time scaling. These different objects are active at the same time. I want to have in settings a slider for people to adjust these time scales independently. Specifically, I am talking about a slider for regular game speed, as well as a slider for reading speed. Dialogue/text needs to appear for a certain amount of scaled time, while other objects need to move at an independent time scale. For this, the simplest solution would be to have something like deltaTime2 and timeScale2. Is there a way to get a separate time scaling system, or the best way to mimic a new time scale system?

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 macsimilian · Jan 03 at 09:56 PM 0
Share

If I make my own deltaTime system that manages for multiple timeScales, I suppose I would also need to write my own WaitForSeconds function as well, that waits an amount of time appropriate to the differing possible timeScales, since I use WaitForSeconds a lot...

avatar image macsimilian · Jan 04 at 07:20 AM 0
Share

Am I correct in my assumption that timeScale simply is a constant multiplier of the deltaTime? Also, could I create my own WaitForSeconds that waits for this scaled amount of time to be passed (or past passed), is that how the original implementation works? Thanks!

1 Reply

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

Answer by Eno-Khaon · Jan 04 at 09:58 AM

If you're looking for more than just the difference between Time.time and Time.realtimeSinceStartup (and, by extension, WaitForSeconds() and WaitForSecondsRealtime()), then you would probably need to implement your own timekeeping groups. This is especially true depending on how you intend for Time.timeScale to influence (or not) FixedUpdate() cycles.

As an (incomplete) example of what it might look like:

 public class TimeScalar
 {
     float scale;
     
     public float deltaTime
     {
         get
         {
             return Time.unscaledDeltaTime * scale;
         }
     }
     
     // ...
     // Add other similar elements to read as needed, relative to unscaled values
    // ...
     public TimeScalar(float timeElapsedPerRealtimeSecond)
     {
         if(timeElapsedPerRealtimeSecond <= 0f)
         {
             Debug.LogWarning("TimeScalar(float): Value must be greater than 0");
             timeElapsedPerRealtimeSecond = 1f;
         }
         scale = 1.0f / timeElapsedPerRealtimeSecond;
     }
 }

 // Usage example:
 // 5 seconds elapsed per 1 second realtime
 TimeScalar dialogueScalar = new TimeScalar(5f);
 // 1 second elapsed per 2 seconds realtime
 TimeScalar objectScalar = new TimeScalar(0.5f);
 // etc.
 
 // ...
 
 yield return new WaitForSecondsRealtime(duration * dialogueScalar.scale);
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

136 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

Related Questions

Lowering Time.timeScale and lowering Time.fixedDeltaTime 1 Answer

Time.deltatime is returning 0? 1 Answer

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

TimeScale = 0 crashes Unity 1 Answer

Is there a way to speed up the game more than 100 times? 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