Question by
Andrew2343 · Nov 21, 2016 at 12:07 PM ·
c#unity 4.6update function
What is the command to stop the Update function ingame? (c#)
So i want an object ingame to pass a trigger and stop the update function on a script. How do i do this? i know how to make a trigger to something, but i dont know what the command to stop the Update function is.
Comment
Answer by brunocoimbra · Nov 21, 2016 at 12:50 PM
Just set enabled (variable that every MonoBehaviour have) to false.
using UnityEngine;
public class MyClass : MonoBehaviour
{
private void Start()
{
enabled = false;
}
private void Update()
{
// Update() will not be called if enabled equals false.
}
}
https://docs.unity3d.com/ScriptReference/Behaviour-enabled.html
Your answer
Follow this Question
Related Questions
Why does this condition keep being true even if its not? 0 Answers
Random.Range kepps returing the same value 1 Answer
Is it possible to access Photoshop file (.psd) in Unity3d? 1 Answer
How do I stop my timer by accessing a variable from another script? 2 Answers
Play audio once while condition is met in update function (C#) 2 Answers