Q:

Change Time.timeScale during an animation event - Unity

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.

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?

A:

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

Create a new scene in a project
Add a cube to the scene
Create a new Animator Controller asset
Add the Animator component to the cube and link the Animator Controller asset to it
Select the cube and open the Animation window
Create a new Animation Clip from the Animation window with a duration of 3 seconds and a simple movement curve
Create a new C# Script called ChangeScale with the following code:
using UnityEngine;
public class ChangeScale : MonoBehaviour {

    public void Slowmotion() {
        Time.timeScale = 0.05f;
    }
}

Add the new script to the cube
Add an Animation Event calling the "Slowmotion" method:

Press Play (In the main editor window, not the Animation window)

Hope this helps you find the issue in your setup

