Skip to main content
added 565 characters in body
Source Link

Input.GetAxisRaw might be what you're looking for. In the Input Manager (Edit -> Project Settings -> Input) setup a variable for "Mouse X" and "Mouse Y" (if not already setup [as below]).

enter image description here

Then in code;

public class CameraMove : MonoBehaviour
{
    private Vector2 mouseMovementpos;
    private bool    isPanning;

    public void Start()
    {
        pos = new Vector2();
    }

    void Update()
    {
        if (Input.GetAxisRawGetMouseButtonDown("Mouse1))
 Y"           isPanning = true;

        if (Input.GetMouseButtonUp(1),)
            isPanning = false;

        if (isPanning)
        {
            pos.Set(Input.GetAxisRaw("Mouse X"), -Input.GetAxisRaw("Mouse Y"));
            transform.Translate(pos, Space.World);
        }
    }
}

And use that forFor movement in the rotation of your transformY plane, the value from the mouse must be negated to, unless you with to use inverted controls. Hope this helped.

Input.GetAxisRaw might be what you're looking for. In the Input Manager (Edit -> Project Settings -> Input) setup a variable for "Mouse X" and "Mouse Y" (if not already setup [as below]).

enter image description here

Then in code;

Vector2 mouseMovement = new Vector2(Input.GetAxisRaw("Mouse Y"),
                                    Input.GetAxisRaw("Mouse X"));

And use that for the rotation of your transform. Hope this helped.

Input.GetAxisRaw might be what you're looking for. In the Input Manager (Edit -> Project Settings -> Input) setup a variable for "Mouse X" and "Mouse Y" (if not already setup [as below]).

enter image description here

Then in code;

public class CameraMove : MonoBehaviour
{
    private Vector2 pos;
    private bool    isPanning;

    public void Start()
    {
        pos = new Vector2();
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(1))
            isPanning = true;

        if (Input.GetMouseButtonUp(1))
            isPanning = false;

        if (isPanning)
        {
            pos.Set(Input.GetAxisRaw("Mouse X"), -Input.GetAxisRaw("Mouse Y"));
            transform.Translate(pos, Space.World);
        }
    }
}

For movement in the Y plane, the value from the mouse must be negated to, unless you with to use inverted controls. Hope this helped.

Source Link

Input.GetAxisRaw might be what you're looking for. In the Input Manager (Edit -> Project Settings -> Input) setup a variable for "Mouse X" and "Mouse Y" (if not already setup [as below]).

enter image description here

Then in code;

Vector2 mouseMovement = new Vector2(Input.GetAxisRaw("Mouse Y"),
                                    Input.GetAxisRaw("Mouse X"));

And use that for the rotation of your transform. Hope this helped.