- Home /
Make rotation gameobjects equal to parent
Hi,
I've scripted a amount of GameObjects that are linked to a parent. When I move around in the parent GameObject, the position of the gameobjects change too. There are textMeshes added to the GameObjects. But when I rotate it, The gameobject won't rotate and don't use the parent as a pivot.
How can I fix this problem. I've tried several approaches on Unity Answers, but they only rotate the textMeshes seperatly separately.
So what I want to do is Animate from a begin position to a target position. But when I do that, the rotation isn't correct anymore:
gameobject.transform.position = position = Vector3.MoveTowards (gameobject.transform.position, targetPosition, step);
private GameObject createLetter(string l, Vector3 position)
{
GameObject myTextObject = new GameObject("fontPosition/"+l);
myTextObject.transform.parent = fontPosition.transform;
//myTextObject.transform.RotateAround(fontPosition.transform.position, new Vector3(0, 1, 0), 90);
//float angle = Mathf.Atan2(fontPosition.transform.position.y, fontPosition.transform.position.x) * Mathf.Rad2Deg;
//myTextObject.transform.rotation = Quaternion.AngleAxis (120.0f, fontPosition.transform.position);
//fontPosition.transform.RotateAround (new Vector3 (1, 0, 1), fontPosition.transform.position, 90.0f);
myTextObject.AddComponent<TextMesh>();
TextMesh textMeshComponent = myTextObject.GetComponent(typeof(TextMesh)) as TextMesh;
MeshRenderer meshRendererComponent = myTextObject.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
meshRendererComponent.material = (Material)Resources.Load( "Materials/fontMaterial");;
meshRendererComponent.material.color = Color.white;
textMeshComponent.font = SantasSleighFont;
textMeshComponent.text = l;
textMeshComponent.color = Color.white;
return myTextObject;
}
Try through the inspector? http://answers.unity3d.com/questions/18637/change-pivot-of-parent-game-object.html
Edited: fixed a typo. Took me a while to understand that you were talking about text$$anonymous$$eshes, not 'test$$anonymous$$eshes'.
Answer by jaapkok · Dec 02, 2014 at 11:44 AM
Thanks, I think ive solved my problems by using both position and localPosition. When I move the particles from a begin position I use localPosition to move the particles form begin to end position. I've parented the textMesh instead of the complete gameObject
Your answer
![](https://koobas.hobune.stream/wayback/20220613172907im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
change pivot of parent game object 1 Answer
"Center On Children" programmatically 1 Answer
Fixing pivot points with second gameObject workaround 1 Answer
How to be sure that the parent's position is the same is the child's position? 0 Answers
Objects are destroyed/disfunctional after changing scene 3 Answers