Method 1 - Using PlayerInputManager
I found a nice YouTube video on implementing local coop. She talks about using a PlayerInputManager
to handle multiple player inputs as well as player joining.
Method 2 - Multiple Cameras, No PlayerInputManager
In this How to Create a Split Screen in Unity video the author explains you can just create two cameras as children of their parent player objects, setting the positions relative to the parent and adjusting the Viewport Rect as necessary to split the screen. This seems even simpler but doesn’t handle player joining. However, this Viewport Rect property could be a good way to handle sharing the same camera until players split.
Method 1 vs 2
Looks like neither one of these will work since I’m using Cinemachine? Although PlayerInputManager
may be applicable still.
Testing Methods in New Empty Project
I ran into some issues trying to get the examples I found working in my current project, I think because the player controller that I wrote expects my hero to be a singleton. So I create a new project from scratch to try out some basic concepts.
- I create a world using all 2d squares like this:
- I create a character, also a 2d square but with a different color and prefab it:
- Then I install the new input system by searching
input system
in the Package Manager: - Attach the
PlayerInput
component: - Move the Main Camera to the player prefab