I have a script that should allow the player to look around, but there is some strange behaviour where the camera jumps back to looking forward every frame, i will link a video that shows the script for this and the behaviour of the camera.link text
Try using transform.Rotate() instead. It’s a pretty simple helper function. Let me know if it works.
Hi. Seems you wanted to use euler angles instead of rotation. Try this:
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class CameraLook : MonoBehaviour
{
[SerializeField]
private GhostPart ghostPart;
[SerializeField]
private float lookSensitivity = 10;
private void Update()
{
FindCameraMovement();
}
private void FindCameraMovement()
{
if (!ghostPart.isGhostPartActive)
{
return;
}
float _xRot = CrossPlatformInputManager.GetAxis("Mouse X");
float _yRot = CrossPlatformInputManager.GetAxis("Mouse Y");
_yRot = -_yRot;
Vector3 _rotation = new Vector3(_yRot, _xRot, 0) * Time.deltaTime * lookSensitivity;
Vector3 _currentRotation = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0);
Vector3 _newRotation = _rotation + _currentRotation;
transform.rotation = Quaternion.Euler(_newRotation);
}
}