I found this script on a forum for almost what i was looking for:
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 FixedUpdate(){
transform.rotation = Quaternion.Euler(X_RotationLockedAt, Y_RotationLockedAt, Z_RotationLockedAt);
}
But how do i get it to only freeze on one axis for example freeze on the Y axis but move with the parent object on X and Z, i tried
transform.rotation = Quaternion.Euler.Y = Y_RotationLockedAt;
But it didn’t work… no errors just didn’t work!
Thanks in advance!
You can have y rotation in eulers of a parent using this
– hirenkachaParentYvalue = Parent.eulerAngles.y;then use that in the object which you want to rotate. transform.eulerAngles = Vector3(0, ParentYvalue , 0);