I am trying to have a speed boost effect for my character where their speed is boosted for y seconds. I have a script that adjusts their speed but when I try to use the WaitForSeconds method I am having trouble. Here is my code. The variable walkSpeed is a global variable within the class.
function CWS(){
var newSpeed = 50.0;
var timeDuration = 10;
var defaultWalkSpeed = walkSpeed;
walkSpeed = newSpeed;
yield WaitForSeconds(timeDuration);
walkSpeed = defaultWalkSpeed;
}
Thanks for any help. I have determined that the problem is with the yield line. Whenever I call the method with the yield line there the method never triggers. However without the yield line it runs just fine.
I shouldn’t need to call StartCoroutine. But that seemed to get it working. Thank yall so much for the help. Interesting that it says I don’t need to call it when I really did.