- Home /
Keep child Gameobject's postition when change parent Gameobject's rotation.
Hello guys.
How can I keep the Text "hoang" which is child of my plane always above my plane when i rotate my plane ?
Thanks for your adivce!
You could multiply your rotation of the parent with -1. So if the rotation of your parent gameObject is Vector2(90,0) your child gameObject would be Vector2(-90,0). Then your child is always on top.
Your mean rotation the child object right ? I also doing that to keep my Text always "readable" (sorry my bad english, I dont know how to description it). But I want my text's postition always like the image 1. Any suggestion ? Thanks
Yes, just always change the rotation of the child. like so:
public GameObject parent;
void Update(){
Vector3 newRot = parent.transform.rotation;
newRot.x *= -1;
newRot.y *= -1;
gameObject.transform.rotation = newRot;
}
Answer by ATate · Mar 11, 2021 at 04:12 PM
Option A
Create another gameobject as a parent to both.
Set the ship's location as 0,0,0. Set the label with the required offset in Y.
Move around the parents position, rotate ship directly
Option B
Treat labels as seperate gameobjects that "follow" a ship Gameobject. Set the label position in a script attached to label to be ship.transform.position + Yoffset