corutine WaitForSeconds weird behaviour
sorry for the lack of better question but basicaly i have this code:
.
voidLateUpdate(){
}else{
StartCoroutine(DD(Hit.point, Hit.collider));
}
}
IEnumerator DD(Vector3 point, Collider col){
Debug.Log("hit point: " + point + "\n with: " + col);
yield return new WaitForSeconds(.1f);
}
.
i intended it to slow down the rate of logs coming when the Raycast hit a collider but it has done nothing.
.
maybe at most i noticed when i tried a larger delay float of 10f that the logs where delayed fot that time but then raged back.
.
isn't the point here that the delay happens always when the IEnumerator is called?
.
in the coroutine documentation i could not find the answer.
.
PS: i press twice the space bar and hit enter as the little memo states but i got no line breaks.
Answer by Freakhealer · Sep 20, 2020 at 03:32 PM
i misunderstood the coroutine actions.
.
turns out everything was fine but since i call the coroutine all frames the delay its only noticed in the first coroutine.
.
i had to make a timer for this to work
.
something like:
int delay = 0;
void update(){
if (delay <= 0){
Debug.Log("hit point: " + point + "\n with: " + col);
delay = 50;
}
delay -= time.deltaTime;
}
.
(might have typos just made it on the go, no longer using this system just felt better to answer my own question)
Your answer
Follow this Question
Related Questions
Using a coroutine to increment a for loop? 0 Answers
Problem with nested Start Coroutine in loop 1 Answer
Coroutine does not stop? 1 Answer
Coroutine from Callback doesn't handle yield returns. 2 Answers
Coroutine not executing second time 0 Answers