CinemachineInputProvider OnMouseClick

The mouse movement is a bit jarring, and wondering if i could enable it only to work if the right mouse button was held down. Not sure how you would go about doing that?

I managed to get this working by the following

  1. Add Two new inputs (Look Enable with Interaction Press Only, and Look Cancel with Interaction Release Only)

  1. Updated Inputs
   public void OnLookEnable(InputAction.CallbackContext context)
    {
        if (!context.performed) { return; };

        LookEnableEvent?.Invoke();
    }

    public void OnLookCancel(InputAction.CallbackContext context)
    {
        if (!context.performed) { return; };

        LookCancelEvent?.Invoke();
    }
  1. Reference CinemachineInputProvider in PlayerStateMachine.cs
    [field: SerializeField] public CinemachineInputProvider CinemachineInputProviderScript { get; private set; }

  2. Then i was easy enough to enable the script in an action within PlayerFreeLookState.cs

stateMachine.CinemachineInputProviderScript.enabled = true;

Not sure if the better method would be to create a whole new camera, and manage it that way, but this works pretty well now. On start the camera is not free look, but if you hold the right hand mouse button you can rotate the mouse until you let go.

Well done, that looks like a good approach!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms