Problem in Rotating prefab instance around world origin.

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.

You may want to use RotateAround in your case, because Rotate only applies rotation (that is what’s happening to you now) while RotateAround changes both rotation and position around a point:

butterfly.transform.RotateAround(yourTreeTransform.position, yourTreeTransform.up, 90f * Time.deltaTime);