I attached an object to my player object as a “flag” (literally). I want the “flag” to face the camera at all times while allowing the play object to rotate. I tried to set rotation of the child object (the “flag”) in the Update() function. It worked to a certain extend, but whenever the player object makes a turn, the child object would rotate with the parent object for one frame and then snap back to the right angle. The end result is a constant flickering of the child object.
I couldn’t figure out how to fix this. Any thoughts?
Here’s the code I am using:
var X_RotationLockedAt : int ; //locking the rotation at a certain angle for X
var Y_RotationLockedAt : int ; //locking the rotation at a certain angle for Y
var Z_RotationLockedAt : int ; //locking the rotation at a certain angle for Z
function Update()
{
transform.rotation = Quaternion.Euler(X_RotationLockedAt, Y_RotationLockedAt, Z_RotationLockedAt);
}
Thanks!