Question by
da_la_da_la_ · Jul 25, 2017 at 05:29 PM ·
c#waitforsecondsstartcoroutine
nothing called after WaitForSeconds
I am trying to have the player leave something after it leaves a certain platform if it collides with a certain object.
this is my code:
if (i == 1){
//leave bomb for following player
player = collision.gameObject;
Transform t = transform;
currentPlatform = player.currentPlatform;
StartCoroutine ("Wait");
}
...
public IEnumerator Wait(){
//wait until player moves to new column
print(Time.time);
yield return new WaitForSeconds(5);
print(Time.time);
if (player.GetComponent<PlayerControl> ().currentPlatform == currentPlatform) {
Wait ();
}
}
The first print statement works fine, but everything after that is not called. My timescale is NOT 0, so this is not the problem. Any suggestions?
Comment
Answer by AirMike · Jul 25, 2017 at 06:32 PM
Make sure you are using System.Collections;
And try changing yield return new WaitForSeconds(5);
to yield return new WaitForSeconds(5f);
Your answer
Follow this Question
Related Questions
IENumerator does not work 0 Answers
Automatic reloading issues 1 Answer
C# waitForSeconds Question 1 Answer
why StartCoroutine(SpawnBigTree()); don't work and the float has a error 0 Answers
WaitForSeconds 1 Answer