Hi guys.
I started learning unity using C# yesterday, but I know something about programming (with java).
To learn, I’m trying to develop a simple pong game, but I’ve some trouble with WaitForSeconds.
I think it can be related to the multithread engine.
That’s what i’m doing :
public class BallControl : MonoBehaviour {
bool wait=false;
void Start (){
if (!wait) {
Debug.Log(wait);
StartCoroutine(hi (5.0f));
Debug.Log(wait);
}
move ();
}
IEnumerator hi(float sec){
Debug.Log("wait for "+sec+" seconds");
yield return new WaitForSeconds(sec);
Debug.Log("waited for "+sec+" seconds");
wait = true;
}
void move(){...}
}
When I start the game, the ball does not wait, but the console log is this:
false
false
wait for 5 seconds
waited for 5 seconds
The hi method is called but it seems to be a separated thread.
Any suggestions?