Hi everyone! I made an input action which contains these action maps and actions:
I use it in my InputManager like this:
// property that has MouseDelta stored for other scripts to use
public Vector2 PlayerMouse { get; private set; }
...
// binding value to property
_inputActions.Player.Look.performed += context => { if (Application.isFocused) PlayerMouse = context.ReadValue<Vector2>(); };
_inputActions.Player.Look.canceled += context => { if (Application.isFocused) PlayerMouse = Vector2.zero; };
And this is how I rotate the player’s camera
private Transform _cameraTransform;
private float _lookSensitivity = 2;
private float _cameraRotAngle = 0;
private float _minCameraAngle = -75;
private float _maxCameraAngle = 75;
private void Update()
{
_cameraRotAngle += -_input.PlayerMouse.y * _lookSensitivity;
_cameraRotAngle = Mathf.Clamp(_cameraRotAngle, _minCameraAngle, _maxCameraAngle);
_cameraTransform.localEulerAngles = new Vector3(_cameraRotAngle, 0, 0);
transform.Rotate(new Vector3(0, _input.PlayerMouse.x * _lookSensitivity, 0));
}
Problem is, when I disable the ‘Player’ action map, move my pointer around, and then enable it, my mouse has some insane delta amount and my player starts rotating everywhere. Here’s the clip of it:
I’ve been thinking of resetting the delta value itself, when I reenable ‘Player’ action map, but I don’t think I can do that? Is there any way to solve this problem? Thanks!