I use a script to rotate the camera with a swipe. To rotate, I use the Device Simulator plugin. If I rotate in the inspector, and then try to rotate the camera in the game with a swipe, then the camera will turn immediately to where it was rotated before rotating in the inspector. If anyone doesn’t understand, you can check how it works. The script hangs on the player, and the camera is in the player. I need to make it so that if I change the values of the rotation of the camera in the inspector, and then rotate it in the game, then the camera does not rotate to where it was rotated before the changes in the inspector…
using UnityEngine;
public class PlayerRotation : MonoBehaviour
{
public Transform myCamera;
Vector3 firstPoint;
Vector3 secondPoint;
float xAngle;
float yAngle;
float xAngleTemp;
float yAnleTemp;
private float slowMouseX;
public float sensitivity = 1f;
void Start()
{
yAngle = transform.localRotation.eulerAngles.y;
}
void Update()
{
foreach (Touch touch in Input.touches)
{
if (touch.position.x > Screen.width / 2.5 & touch.phase == TouchPhase.Began)
{
firstPoint = touch.position * sensitivity;
xAngleTemp = xAngle;
yAnleTemp = yAngle;
}
if (touch.position.x > Screen.width / 2.5 & touch.phase == TouchPhase.Moved)
{
secondPoint = touch.position * sensitivity;
xAngle = xAngleTemp - (secondPoint.y - firstPoint.y) * 90 / Screen.height;
yAngle = yAnleTemp + (secondPoint.x - firstPoint.x) * 180 / Screen.width;
transform.rotation = Quaternion.Euler(0, yAngle, 0);
xAngle = Mathf.Clamp(xAngle, -80, 80);
myCamera.transform.rotation = Quaternion.Euler(xAngle, yAngle, 0);
}
}
}
}