Hello
I have 2 gameobject the first one is parent and the second is child , if the parent gameobject rotate the child gameobject rotate too, and I want to freeze the child object from rotation…
thx…
Hello
I have 2 gameobject the first one is parent and the second is child , if the parent gameobject rotate the child gameobject rotate too, and I want to freeze the child object from rotation…
thx…
I didn’t test this, but I believe that you can just set the child transform.rotation to a fixed value in LateUpdate to eliminate any parent-originated rotation. You can save the initial child rotation at Start, like below (attach this to the child):
var iniRot: Quaternion;
function Start(){
iniRot = transform.rotation;
}
function LateUpdate(){
transform.rotation = iniRot;
}
NOTE: If the parent is being moved by physics you may have problems, because physics runs at its own pace, and a cycle may occur between LateUpdate and the scene rendering.
this script work . attach with child object … ![]()
function Update () {
var rotation = Quaternion.LookRotation(Vector3.up , Vector3.forward);
transform.rotation = rotation;
}
Liking the simple solution. But what if I want to freeze the X and Z axis only?
I get an error when using transform.rotation.y = rotation.y ?
thanks for the script !..was having same problem
– MiraiTungaMany thanks to you sir.
– Tito_TrujilloGracias, el efecto final es increíble.
– SaturnoMichaelLiking the simple solution. But what if I want to freeze the X and Z axis only? I get an error when using
– andyjoetransform.rotation.y = rotation.y ?