I’m trying to make it so on a trigger it starts the coroutine and in the IEumerator i want to use waitforseconds to do something.
Right now I can do the StartCoroutine(“my method”()); in the trigger event and it works up until the waitforseconds method.
using UnityEngine;
using System.Collections;
public class PowerUpFire : MonoBehaviour {
public bool isHit = false;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void test()
{
Debug.Log("TEst");
}
void OnTriggerEnter2D(Collider2D collision)
{
Destroy(gameObject);
PlayerController.health = 500f;
startIn();
}
public void startIn()
{
StartCoroutine(waitCouple());
}
IEnumerator waitCouple()
{
print("tda");
Debug.Log(Time.time);
yield return new WaitForSeconds(3);
Debug.Log("ADD");
}
}