Hi,
I have just started with unity and I have bee trying to create a scene with a tree and flying butterflies around it. I downloaded tree and butterfly from Unity Asset Store. I have everything up and butterflies wings flap is preanimated in models. I have given my prefab instances a Tag named “Butterfly” now I am trying to rotate these butterflies around the tree. I am using Transform.Rotate
for this purpose in update fucntion like this :
GameObject[] butterflies = GameObject.FindGameObjectsWithTag("Butterfly");
Debug.Log("Outside Loop: " + butterflies.Length);
foreach(GameObject butterfly in butterflies)
{
Debug.Log("Found some butterflies with tag: " + butterfly.tag);
butterfly.transform.Rotate(new Vector3(0.0f, 1.0f, 0.0f), Time.deltaTime * 90.0f,
Space.World);
}
So no matter whether I use Space.World
or Space.self
they are only rotating at their place and not around tree. My tree is at origin.