Cinemachine Input Provider not correctly using Player Index

Hello Everyone,

I have set up Split-screen using Unity’s Player Input Manager. I am able to load a prefab of a player and give individual control to each player via controller.

The problem arises when I set player index in CinemachineInputProvider. CinemachineInputProvider playerIndex tooltip states “Which player’s input controls to query. Leave this at the default value of -1 for single-player games. Otherwise this should be the index of the player in the UnityEngine.Inout.InputUser.all list”.

Following this advice, I assign P1 a playerIndex value of 0 and P2 a playerIndex value of 1 at runtime, after the prefab is instantiated by the player input manager, join when player button is pressed. (Images referenced below)

I can confirm that P1’s playerIndex is 0 and P2’s playerIndex is 1 by referencing the index values provided by InputUser.

InputUser.all[0].index
InputUser.all[1].index

However, when I attempt to use the right thumbstick on either controller, both cameras move. Am I misunderstanding playerIndex?

Testing with:
Player 1: Xbox One Controller
Player 2: Dualshock 4 Controller

Unity Version: 2019.3.11f1
Cinemachine Version: 2.6.2
Input Sytem: 1.0.1

6690031--767446--P1_CinemachineInputProvider.png
6690031--767449--P2_CinemachineInputProvider.png

I figured it out. I had 2 different Input Actions :roll_eyes:

Controls and GamepadLookControls.

Each player prefab was loaded with a reference to Controls. The attached Freelook Virtual Camera had a reference to GamepadLookControls, not Controls. Setting the XY Axis input to Controls solved the issue for me!

1 Like