0
\$\begingroup\$

I have an animation. A few seconds after this animation starts I set an animation event that is correctly being triggered. This animation event calls a method where I am trying to modify Time.timeScaleand set it to 0.05f.

enter image description here

This event is calling the following method:

public void Slowmotion()
{
    Time.timeScale = 0.05f;
    //Time.fixedDeltaTime = Time.timeScale * 0.02f;
}

But this Slowmotion method is not working.

Any ideas on what may be happening?

\$\endgroup\$
0
\$\begingroup\$

I made a scene based on your question and the "Slowmotion" method worked just fine, the steps I followed were:

  1. Create a new scene in a project
  2. Add a cube to the scene
  3. Create a new Animator Controller asset
  4. Add the Animator component to the cube and link the Animator Controller asset to it
  5. Select the cube and open the Animation window
  6. Create a new Animation Clip from the Animation window with a duration of 3 seconds and a simple movement curve
  7. Create a new C# Script called ChangeScale with the following code:

    using UnityEngine;
    public class ChangeScale : MonoBehaviour {
    
        public void Slowmotion() {
            Time.timeScale = 0.05f;
        }
    }
    
  8. Add the new script to the cube

  9. Add an Animation Event calling the "Slowmotion" method: Slowmotion Animation Event
  10. Press Play (In the main editor window, not the Animation window)

Hope this helps you find the issue in your setup

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.