Hi everyone,
I am using Unitys Input System to create a local multiplayer game. I have the current code configured for my inputs which works great for one player, the code below rotates the camera
void Movement()
{
cameraInputMovement = playerActionControls.Camera.OnRotation.ReadValue<Vector2>();
//Multiply the X and Y Axis by the speed the player should move at
x += cameraInputMovement.x * xSpeed * Time.deltaTime;
y -= cameraInputMovement.y * ySpeed * Time.deltaTime;
//clamps the Y angle to the limits specified
y = ClampAngle(y, yMinLimit, yMaxLimit);
//Use the X and Y axis for rotation
Quaternion rotation = Quaternion.Euler(y, x, 0);
//Get the distance from the target
Vector3 negDistance = new Vector3(0, height, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
The problem is, when I add another player in using the Player Input managers split screen functionality, the camera rotation input controls both players camera rotation. I figured out that I can assign Unity Events to the Player Input component on the player to get around this problem, so I changed my code to the below:
//This function is assigned on the player input component as a unity event
public void OnRotate(InputAction.CallbackContext context)
{
cameraInputMovement = context.ReadValue<Vector2>();
Debug.Log("moving");
}
void Movement()
{
//cameraInputMovement = playerActionControls.Camera.OnRotation.ReadValue<Vector2>();
//Multiply the X and Y Axis by the speed the player should move at
x += cameraInputMovement.x * xSpeed * Time.deltaTime;
y -= cameraInputMovement.y * ySpeed * Time.deltaTime;
//clamps the Y angle to the limits specified
y = ClampAngle(y, yMinLimit, yMaxLimit);
//Use the X and Y axis for rotation
Quaternion rotation = Quaternion.Euler(y, x, 0);
//Get the distance from the target
Vector3 negDistance = new Vector3(0, height, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
Unfortunately, with this method, no inputs are picked up at all, not even the Debug Message. It should be noted that the Player Input component is on the player, but this camera script is on the Main Camera, which is a child component of the player, not sure if that matters.
Does anyone know why no inputs are being picked up?

