I have an odd problem, that I hope is just a setting. I have a snake model that turns his head to look at the player, when the player moves along the Z or X axis. The code works perfectly in the scene, but will not run in the game. I can watch the snake head track the player camera in scene, but it’s frozen in game. Here is the code:
private void LateUpdate()
{
lookVector.x = (Player.transform.position.z * 1.5f) - 30;
lookVector.z = -Player.transform.position.x;
lookVector.y = 0;
//lookVector.y = transform.position.y;
Quaternion rot = Quaternion.Euler(lookVector);
transform.localRotation = Quaternion.Slerp(transform.rotation, rot, 1);
}
I put the code in LateUpdate() because I was originally trying to override the animator controller, but that didn’t do anything so I decided to manually manipulate the bone. I’ve also tried this code in regular Update() and same result. The script is directly attached to the Snake’s NeckBone that needs to be rotated.
I even updated Unity to 2019.3.12f1. What would cause the bone script to work perfectly in the scene, but not work at all in game?
Any help is appreciated.
Thank you