Hello! I am working on my input system and I would like to change a variable based on which control scheme is currently being used. I am using the new input system and have two control schemes set up, “Gamepad” and “Mouse & Keyboard”. I was using bits of code from the 3D unity starter assets but the way I have my input set up is slightly different and is causing me some issues. The code I am attempting to run is here :
#if ENABLE_INPUT_SYSTEM
private PlayerInput _playerInput;
#endif
private bool IsCurrentDeviceMouse
{
get
{
#if ENABLE_INPUT_SYSTEM
return _playerInput.currentControlScheme == "Mouse & Keyboard";
#else
return false;
#endif
}
}
private void CameraRotation()
{
// if there is an input and camera position is not fixed
if (_input.LookValue.sqrMagnitude >= _threshold && !LockCameraPosition)
{
//Don't multiply mouse input by Time.deltaTime;
float deltaTimeMultiplier = IsCurrentDeviceMouse ? 1.0f : Time.deltaTime;
_cinemachineTargetYaw += _input.LookValue.x * deltaTimeMultiplier * Sensitivity;
_cinemachineTargetPitch += _input.LookValue.y * deltaTimeMultiplier * Sensitivity;
}
However, my player was not using the “Player Input” component before and adding it now causes loads of "MissingMethodException : Method ‘InputReader.OnLook’ not found (for context, the InputReader is the script that actually handles input from the player and passes it on to the player object, example :
public void OnLook(InputAction.CallbackContext context)
{
LookValue = context.ReadValue<Vector2>();
}
)
is there a way to check which control scheme is being used without the Player Input component? Or is that simply the best way to do it and I need to figure out how to make it work with my current setup?