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;
}