I’m trying to figure out how to combine the new input system manager (with split screen enabled) and Cinemachine.
I linked a camera and a virtual camera in the player prefab, its hierarchy looks like this :
PlayerHolder
– Player
– PlayerCamera
– PlayerVirtualCamera
When the first player joins in, everything is fine, but as soon a the second one enters the game, the virtual camera pans to the second player on both screens.
Is Cinemachine compatible with the new input system? I know that Cinemachine works with split screen, as Unity made a Youtube tutorial about it:
Hey! What I ended up doing is writing a setup script and change the VM cams and regular cams when a player is joining.
using UnityEngine;
public class PlayerManager : MonoBehaviour
{
public Camera cam;
public GameObject virtualCam;
public void Setup(int layer)
{
virtualCam.layer = layer;
var bitMask = (1 << layer)
| (1 << 0)
| (1 << 1)
| (1 << 2)
| (1 << 4)
| (1 << 5)
| (1 << 8);
cam.cullingMask = bitMask;
cam.gameObject.layer = layer;
}
}
I keep a List of PlayerInput somewhere in the app (in my case, in a scriptable object) hooked up to Player Input Manager’s events, and assign layers based on their index in this list.
At the moment, split-screen in Unity is not compatible with Cinemachine. I came across this post looking for a guide to local multiplayer in Unity and then accidentally found the answer to your problem in Unity’s new input system documentation.
Hey @MarNevGames , events are fired by the buil-in Player Manager, i did not set them. You can just hook your function like you do with UI buttons for example.