Creating the Second Player | Making Your First Game in Godot

With the ball created and bouncing correctly why not add a second player into the mix to make it a real game?

Duplicating the Original Paddle

The easiest way to create second player is by duplicating the existing PlayerPaddle Node. After duplicating, we can position the second player’s paddle on the other half of the field. I used the same X offset from the goal zone but positioned it lower on the Y. Running the scene right now shows a blaring problem… both paddles move at the same time!

Multiple Player Paddles

Flipping the Script

For a more polished game we would need a more robust solution but since we are keeping a low scope, basic game we can just duplicate the contents of the script. This starts by detaching the existing script from the second paddle and creating a brand new script for Player 2. We can take the contents of the original paddle script and paste them into the new one. Mostly everything will stay identical except for the inputs. To tweak this, we’ll need to add new inputs in the Input Map for Player 2. I set these to the Up Arrow and Down Arrow. The last thing is to fix the Input Checking in the script to make sure it is looking for the new inputs.

PlayerPaddle2 Script

With all this set we should have two independent paddles moving with their own inputs and the ball should appropriately bounce off each. If the ball goes off screen, it should reset after a short wait. The final step is to create our scoring mechanism.