Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Rotate Object/Camera by Mouse

    Vector3 currentCameraEulers;
    float rotationDPI = 7f; 

    void Update()
    {
        float cameraX = Input.GetAxisRaw("Mouse X") * rotationDPI;
        if (cameraX != 0f)
        {
            currentCameraEulers = new Vector3(0, cameraX, 0);
            transform.eulerAngles += currentCameraEulers;
        }
        float cameraY = Input.GetAxisRaw("Mouse Y") * rotationDPI;
        if (cameraY != 0f)
        {
            currentCameraEulers = new Vector3(cameraY, 0, 0);
            transform.eulerAngles += currentCameraEulers;
        }
    }
 
PREVIOUS NEXT
Tagged: #Rotate #Mouse
ADD COMMENT
Topic
Name
7+9 =