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
0
Question by ExcellS23 · Mar 25, 2016 at 07:48 PM · timertime.deltatimetimescalehowtime.timescale

Slow Motion Issues!

Hi Guys,

I am currently having issues with trying to "temporarily" slow down time after the player is hit. I have read around the forums and answers and can't figure out why my code isn't working.

 //These Methods are in the same Class..

 public void TakeDamage(int atkdmg, int animeControllerNum) {
 hurtIdentifier = animeControllerNum;
 currentHealth -= atkdmg;
 healthSlider.value = currentHealth;
 _tookDamage = true;
 timeScaleTimer = scaleTimerVal; // (scaleTimerVal set to 2f) to set the timer to control when the game should go back to regular 1f time scale
 _turnSlowMoOn = true; 
 }
 
 void Update() {
 timeScaleTimer -= Time.deltaTime; 
 
 if (timeScaleTimer <= 0) {
 
 timeScaleTimer = 0;
 _turnSlowMoOn = false;
 }
 
 if (_turnSlowMoOn) {
    if (Time.timeScale == 1f) {
     Time.timeScale = .5f;
     }
  else {Time.timeScale = 1f;
     Time.fixedDeltaTime = .02f * Time.timeScale;
             }
         }
 
 
 

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 Downstream · Mar 25, 2016 at 08:13 PM 0
Share

When you ask this sort of question you should describe the behavior you're encountering.

Where's the sense in setting Time.timeScale to 1 when you've already checked that it is 1. Why are you changing Fixed delta time, as it's tied to deltaTime? "Note that the fixedDeltaTime interval is with respect to the in-game time affected by timeScale."

avatar image ExcellS23 Downstream · Mar 25, 2016 at 09:50 PM 0
Share
  1. I am not encountering anything.. that is why I am asking the question..

  2. I am changing FixedDelta time so that the physics engine can be updated as well.(http://docs.unity3d.com/ScriptReference/Time-timeScale.html).

  3. Thanks for responding

  4. I am fairly new to the Game Program$$anonymous$$g world.

1 Reply

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

Answer by ryan_unity · Mar 25, 2016 at 09:21 PM

Hey, it looks like the time scale will be flipping between 1 and 0.5 each frame when _turnSlowMoOn is true. Can you try changing it to something like:

 if (_turnSlowMoOn) {
     Time.timeScale = 0.5f;
 }
 else {
     Time.timeScale = 1.0f;
 }
 Time.fixedDeltaTime = 0.02f * Time.timeScale;
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

55 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

Related Questions

Load scene after time 1 Answer

Is UI affected by time scale ? 1 Answer

Respawn issues 2 Answers

How to Make Timer (Score) Count Up Faster? 1 Answer

Why is my Unity Game crashing whenever Time Left is close to 0? 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