Step 2: Scripting the bat
We'll make the bat swing when we press the left arrow key on the keyboard. Right-click on the bat, and select Add Script.
First we'll need to detect when the key is pressed. Click on Events, and drag out the block called "When the player presses key backspace".
Click on 'backspace' and change it to 'left arrow'.
To make the bat swing, we'll change its rotation. Grab the "set rotation of myself" block (from Transform) and drag it inside this event. Set the rotation to -90.
To make the bat reset to a neutral position, we'll rotate it back to the way it was after a short amount of time has passed. Grab the "100 milliseconds have passed" block (from Control Flow), and drag it under the rotation block.
Inside this block, drag another "set rotation of myself" block, and set the rotation to 0.
Now we can play the game to test it out. Click the Play button in the top-right corner.
Before the game starts playing, you'll need to save this script. Name it 'bat' and then click Done.
Now that the game is running, when you press the left arrow key you'll see the bat rotate.