Question by
edgartip2003 · Apr 22, 2019 at 03:31 PM ·
c#script.coroutine
How to make a scrip stop a coroutine from another script?
Hey guys ! How do I make a script stop a coroutine that is active in another screen? Would love suggestions!
Comment
There is StopCoroutine method StopCoroutine
Or if it does not work try disabling and enabling script that has coroutine that you want to stop, because as i remember it automatically stops every coroutine that script is running.
Could you help me say what is wrong with my script? Thanks for the suggestions though.
SCRIPT 1
public GameObject blueswitch;
void OnTriggerEnter2D(Collider2D collision){
if (collision.tag == "Deathlimit" && EndDoorTouched == false)
{
blueswitch.GetComponent<BlueDoorScript>().CancelCoroutine();
}
}
SCRIPT2
public void CancelCoroutine(){
StopCoroutine(ButtonTimer());
}
Your answer
Follow this Question
Related Questions
WaitForSeconds in Coroutines do not work. 0 Answers
What is Coroutine, Yiel and IENumerator? 1 Answer
Smoothly multiply float 0 Answers