Problem is not reproducible or outdated
Camera rotation error: "Input rotation is { NaN, NaN, NaN, 1.0000 }
I'm getting the error "transform.localRotation assign attempt for 'Main Camera' is not valid. Input rotation is { NaN, NaN, NaN, 1.000000 }.". The problem with this is that as far as I can tell I'm not doing anything that should result into NaN being fed into the offending method. The error message points to line 69 of this script. For context, I'm building up my own third person controller, and I've basically cannibalized the Standard Assets MouseLook script. My controller script is:
[SerializeField]private ThirdPersonMouseLook MouseLook;
public float Debug_TimeScale;
public GameObject EscMenu;
private CapsuleCollider PlayerCapsule;
private Rigidbody PlayerRigidbody;
private Animator PlayerAnimator;
private Vector3 CapsuleCenter;
private float CharHeight;
private bool CameraEqualPlayerRotation;
private void Start ()
{
Time.timeScale = Debug_TimeScale;
PlayerCapsule = GetComponent<CapsuleCollider>();
PlayerRigidbody = GetComponent<Rigidbody>();
PlayerAnimator = GetComponent<Animator>();
CapsuleCenter = PlayerCapsule.center;
CharHeight = GetComponent<MeshFilter>().mesh.bounds.extents.y;
PlayerRigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
MouseLook.Init(transform, Camera.main.transform);
EscMenu.SetActive(false);
}
private void Move ()
{
if (Input.GetKey(KeyCode.W)) {PlayerAnimator.SetBool("Forward", true);} else {PlayerAnimator.SetBool("Forward", false);}
if (Input.GetKey(KeyCode.A)) {PlayerAnimator.SetBool("Left", true);} else {PlayerAnimator.SetBool("Left", false);}
if (Input.GetKey(KeyCode.D)) {PlayerAnimator.SetBool("Right", true);} else {PlayerAnimator.SetBool("Right", false);}
if (Input.GetKey(KeyCode.S)) {PlayerAnimator.SetBool("Back", true);} else {PlayerAnimator.SetBool("Back", false);}
if (Input.GetKeyDown(KeyCode.LeftControl) && PlayerAnimator.GetBool("Crouch")) {PlayerAnimator.SetBool("Crouch", false);}
else if (Input.GetKeyDown(KeyCode.LeftControl)) {PlayerAnimator.SetBool("Crouch", true);}
if (Input.GetKeyDown(KeyCode.T) && PlayerAnimator.GetBool("Walk")) {PlayerAnimator.SetBool("Walk", false);}
else if (Input.GetKeyDown(KeyCode.T)) {PlayerAnimator.SetBool("Walk", true);}
}
private void EscMenuCheck()
{
if (Input.GetKeyDown (KeyCode.Escape) && !EscMenu.activeInHierarchy)
{
EscMenu.SetActive(true);
Time.timeScale = 0;
MouseLook.SetCursorLock(false);
MouseLook.XSensitivity = 0f;
MouseLook.YSensitivity = 0f;
}
else if (Input.GetKeyDown (KeyCode.Escape))
{
EscMenu.SetActive(false);
//Time.timeScale = 1;
Time.timeScale = Debug_TimeScale;
MouseLook.SetCursorLock(true);
MouseLook.XSensitivity = 2f;
MouseLook.YSensitivity = 2f;
}
}
private bool GroundCheck()
{
if (Physics.Raycast (transform.position, Vector3.down, CharHeight/2f)) {return true;}
else {return false;}
}
private void Update()
{
MouseLook.LookRotation(gameObject.transform, Camera.main.transform);
EscMenuCheck();
Move();
}
private void FixedUpdate()
{
MouseLook.UpdateCursorLock();
}
I really can't see anything here that would result in this problem. Any help would be really appreciated.
Alright, I fixed this. The Game Object didn't actually have a mesh filter, so when I referenced the non-existent mesh filter it caused this problem.