Unity Pong Multiplayer
Classic pong game with network multiplayer.
Press SPACE key to start the game. Only the HOST can start the game.
Press UP ARROR and DOWN ARROW to move the paddle upwards and downwards.
Host player is always spawned on the right field, while client player on the left field.
The paddle contains a kinematic RigidBody2D with a Polygon2D collider. This polygon enables to build a non-rectangular collider in order to allow the user more flexibility while hitting the ball.
The paddle is moved at a certain velocity and clamped to avoid losing it outside the field.
PaddleController is the base class controlling the paddle movement and limitations. Child classes, like PlayerController, enable to specify the control keys (W/S or ARROWS).
The ball contains a script used to detect collisions (with lose triggers), respawn and inform score manager.
Aroud the field there are four colliders:
- Two for the floor and ceiling, with a Physic2D material bouncing.
- Two for the left and right walls. These ones are the colliders controlling the scores.
PongNetworkManager takes care of starting the game when two players are connected (only the host can start the game). The ScoreManager class synchronizes its variables in order to be displayed in both clients, and two prefabs (Ball and Player) are spawned. Player prefab is Local Player Authority in order to allow user control.
Starting the game
One client must start as HOST using the UNet HUD provided, while the other one must connect as a LAN Client. The host IP needs to be provided to the second client to be able to connect.
- Create proper art (and resolution) for scores.
- Fix possible infite loops when ball bounces vertically against the walls.
- Implement a turn-based game start.
- Pack all assets in a SpriteSheet and create AssetsBundle in order to download season related assets. Implement particle systems and sound and include them in the AssetBundle.