Je lutte depuis quelques temps pour trouver comment stopper une coroutine et la relancer...
Je cherche à détecter la mort du joueur, stopper la coroutine et la relancer juste après lors d'un event quelconque.
Quelqu'un aurait-il une idée ?
Merci
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
public class TimerTest : MonoBehaviour {
public GameObject drop;
public float Begin = 1; //time on
public float End = 1; //time off
void Start () {
StartCoroutine("Flicker"); //start coroutine
}
void Update () { //Où pourrais-je tester / savoir que mon perso est mort en dehors d'update ?
if (LifeSystem.CamRespawn == true) // if we die
{
StopCoroutine("Flicker"); // Stop then restart
Debug.Log ("Stop");
//StartCoroutine("Flicker"); ???
}
}
IEnumerator Flicker(){
while(true){
yield return new WaitForSeconds(Begin);
gameObject.renderer.material.color = Color.green;
yield return new WaitForSeconds(End);
gameObject.renderer.material.color = Color.black;
}
}
}