Using the new Input System

If you are using the New Input System, to detect Mouse Down, below is the code to detect a continuous mouse down (PlayerActions is name of the Input Script - yours may be different)


private void Update()
{
   float mouseDown =  playerInputActions.Player.Movement.ReadValue<float>();
}

private void MoveToCursor()
{
   if (mouseDown > 0)
   {
      /// code here
   }
}
1 Like

A great tip.

You can also use:

{
    if(Mouse.current.IsPressed())
    {
          //code here
    }
}
1 Like

Privacy & Terms