So the animation takes 1 second, but I want it to take 2 seconds and let player wait for a second after the texture has moved. Everything is working, the invoke part is not working. When I try invoke, the animation does not happen at all.
Invoke(“foo”, 2) means invoke foo in 2 seconds not run foo for 2 seconds. So foo won’t do anything for 2 seconds and then it will execute. Did you wait that long?
Can’t say on the rest of your script as it looks really dependent on your set up.
When you say nothing happens do you mean just the animation, or does the audio clip at the start not play either? If the audio doesn’t play, it suggests the function isn’t being called at all (you can double check this by adding a Debug.Log to the start of the function). Is it possible that you are calling CancelInvoke somewhere else in the code?
Allright it works, but not exactly the way I wanted it to work. Yes previously it was only animation which was not working and I am not calling cancelInvoke anywhere else in the code…
So as you know, previous code does animation after 2 seconds. What I wanted to do, is block the clicking of button while the animation is playing. Otherwise, player keeps on playing and animation happens lots faster and spoils the game mechanics. With the above code, It holds for 2 seconds, but the clicking thing goes on… I guess I need to overlap buttons by 3d cubes when the animation is happening to stop players further clicking the button…