- Home /
How to turn off Script at the start of animation, ant turn on at the end of it.
Hello to everyone, I am wondered by a question, how can we turn off the scripts for example of control and play an animation, and then turn them back on, so the cut scene may be clean will be clean. If anybody has an idea please help.
Answer by 334499p · Aug 15, 2015 at 07:58 AM
You could use a boolean variable to let the script know whether or not it can operate. When the animation starts then set the boolean to false. Create an if statement in your update function that only calls if the boolean is true so that it can avoid calling any unwanted functions when the animation is playing. When the animation is done then set the boolean back to true.
Answer by amnauet09 · Aug 15, 2015 at 02:01 PM
GameObject.Find ("NameOfGameObjectToWhichTheScriptIsAttached").GetComponent<ScriptName>().enabled = false;
Or you can enable the script in a similar manner.
Your answer
![](https://koobas.hobune.stream/wayback/20220611235952im_/https://answers.unity.com/themes/thub/images/avi.jpg)