I have a class file that zooms the camera for aiming. I also have a zoom animation for my gun. What i want to do is wait for the gun to catch up some before i do the camera zoom. It zooms by the right mouse button down event
However, it just doesnt seem to do anything like the function is not being called. I have looked at numerous examples and i dont see what i am doing wrong?
UPDATE: I got it fixed. I will revise my code to reflect that incase anyone else has problems down the road.
Every example i have tried has not worked.
It seems to actually work perfectly in your code.
Starting a coroutine means "executing another piece of code at the same time that your current piece of code". So you're just "waiting" but this does only pause the coroutine code... not the main "thread".
Even if it doesn't seem to wait 5 seconds it actually does, but not in your main execution thread that's why it seems buggy for you.
I would suggest something using a boolean to control your flow. Something like this:
I did not read the code carefully to trace it and see what in each state will happen but your coroutine is returning IEnumerable instead of IEnumerator and it should be the reason for it to not work.
answered Aug 27, 2012 at 07:35 AM