Integrating throwing animation in Coin distraction activity
In my previous post, pressing right-click immediately instantiated the coin on the ground and the guards immediately checked the area. However to make it more realistic, we have to turn the player to the direction where the coin will be thrown, perform the throw animation, instantiate the coin and then let the guards check the area.
You need to coordinate the events similar to Timeline. That being said, I used booleans and WaitForSeconds to control the sequence of events.
First, if the right-click is pressed, we need to stop the walk animation if it’s running then perform the sequence of events needed to throw the coin:
With booleans, WaitForSeconds and conditional statements we can control the sequence of events.
Based on the code above, we rotate the Player to the direction of the coin to be thrown, perform the throw animation and then instantiate the coin.
Now, distracting the guards looks more natural.