Answer the question
In order to leave comments, you need to log in
Camera rotates incorrectly in Unity?
I wrote the following script to rotate the camera by mouse movement:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestScript0 : MonoBehaviour
{
private Vector3 LastMousePosition;
private Vector3 NowMousePosition;
// Start is called before the first frame update
void Start()
{
LastMousePosition = Input.mousePosition;
}
// Update is called once per frame
void Update()
{
NowMousePosition = Input.mousePosition;
transform.Rotate(0, NowMousePosition.x - LastMousePosition.x, 0);
transform.Rotate(LastMousePosition.y - NowMousePosition.y, 0 ,0);
LastMousePosition = NowMousePosition;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question