findWithTag

1 minute of your time can help me alot :wink:

public void RotationDownButton ()
{
transform.Rotate (-rotationSpeed * Time.deltaTime, 0, 0);
GameObject.FindWithTag (“Model”).transform.Rotate (-rotationSpeed * Time.deltaTime, 0, 0);
}

when i use only 1 object with tag “Model” everything are good
but when im using 2 or more object and i use same tag “Model”, the rotation is not working anymore

Hello! :smile: the .FindWithTag onlly returns one gameobject :slight_smile: See documentation here → Unity - Scripting API: GameObject.FindWithTag Hope that helps!

i was thought tag can call many object

so how we can call multiple object in 1 method ?
if i have 2 object called object1 and object2

public void RotationDownButton ()
{
GameObject.Find (“object1, object2”).transform.Rotate (-rotationSpeed * Time.deltaTime, 0, 0);
}

tried but that object only shaking hardly without do any rotation
but if i use only one object GameObject.Find (“object1”).transform.Rotate (-rotationSpeed * Time.deltaTime, 0, 0);
i can rotate the object normally

You want this:

Unity - Scripting API: GameObject.FindGameObjectsWithTag :smile:

EDIT: But remember you will have to loop through all the objects. :slight_smile: There is a good code example in the docs :slight_smile: hope that helps!

public GameObject[ ] Models = GameObject.FindGameObjectsWithTag(“Model”);

public void RotationDownButton ()
{
Models.transform.Rotate (-rotationSpeed * Time.deltaTime, 0, 0);
}

i was trying to rotate all gameobject with same tag. but transform didnt work to Models because FindGameObjectsWithTag return you string.
and i dont know how to call them, so i can rotate all gameobject with tag “model”
anyone can help me?