- Home /
FindGameObjectsWithTag and add rotation?
Hello,
I have multiple Icons on my map that should all rotate around the y-axis and I don't know how to interagate with them all stored in that findgameobjectswithtag-array:
private var icons : GameObject[];
function Start () {
icons = GameObject.FindGameObjectsWithTag("Icons");
}
function Update () {
icons.gameObjects.transform.Rotate(Vector3.up);
}
Answer by tanyanzhi · May 30, 2015 at 07:07 PM
you can try this in function Update:
for (var i=0;i<icons.length;i++)
{
icons[i].transform.Rotate(Vector3.up);
}
Answer by lizard4455 · May 30, 2015 at 07:07 PM
Perhaps you could try using a for loop or foreach loop to individually change the rotation of each GameObject in the array "icons"?
Your answer
Follow this Question
Related Questions
Rotate GameObject Issue 1 Answer
Use an objects (from array) position to focus a camera on 3 Answers
When fliping the character the rotation of character's weapon goes backward 0 Answers
Cannot convert 'UnityEngine.Collider[]' to 'UnityEngine.gameObject[]' using OverlapSphere 3 Answers
Detection if a GameObject is below you or next to you? 1 Answer