Local Multiplayer
After refining the player movement, it was time to extend these controls to a second player. Unity’s new Input System includes a Player Input Manager, that is designed to allow for easy implementation of local multiplayer, by automatically joining a player to the scene for each separate input device. While this drop in/drop out style of multiplayer worked as a proof of concept, several issues arose surrounding the join order of players, often with the delegation of a single controller to multiple instances of a player. As the plan was to extend local multiplayer to up to four players, it was necessary to write a script to manually spawn each player and assign separate input devices to each. As the game currently lacked a UI or menu system at this stage, the player ships were simply spawned in sequentially at the start of the game, so that each input instance was assigned correctly. Initially, each player had a fixed spawn point, but this allowed for spawn camping. So, the hyperdrive script was modified to handle initial spawns and respawns, randomizing the position each time. The trade-off, however, is the narrow possibility of spawning on or near the central star, or another player.
With local multiplayer now working, it became apparent that the addition of more players would quickly outgrow a fixed screen area. To fix this, a dynamic camera was created that tracks each player, moving and expanding the viewport to keep everything in frame. While this could have been implemented using the Cinemachine group camera, I instead decided to write a custom script to handle camera tracking, to limit external package dependencies, and correct some visual jitter caused by a discrepancy between the player and camera movement.
Super Spacewar!
Status | Prototype |
Author | Codemyster |
More posts
- DocumentationMay 26, 2023
- Polish and UIMay 26, 2023
- Presentation and GraphicsMay 26, 2023
- Weapons and Power UpsMay 26, 2023
- Player MovementMay 26, 2023
- Game TestingMay 20, 2023
- Game ConceptApr 14, 2023