Toss A Coin To Your W-… Security Guard. (Part 1)
Today I’m giving the player’s character, a thief, the ability to toss a coin to distract the security guards, moving them to another location.
Today’s Objective: Create the coin toss ability, making a coin spawn at the position the player right-clicks at.
The Code:
In my previously created “PlayerControl” class, I will add the variables needed for this ability:
In Update( ), I add a check for the right mouse button click:
The TossCoin( ) method is a coroutine so that I can have delays between code executions for the event.
As for the actual coin toss code, it is as follows, and goes in the position marked above:
And that’s it for the coin toss ability itself!
Now obviously this doesn’t make the guards aware of it. I will cover that in my next post, Part 2.
I will also be working on making the coin toss an actual toss, rather than a spontaneous appearance, in Part 3.
Thanks for reading! Stay tuned for the following parts in the next 2 days!