Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

findWithTag

Discussion in 'Editor & General Support' started by herllycules, Sep 30, 2015.

  1. herllycules

    herllycules

    Joined:
    Sep 23, 2015
    Posts:
    4
    1 minute of your time can help me alot ;)

    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
     
  2. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
  3. herllycules

    herllycules

    Joined:
    Sep 23, 2015
    Posts:
    4
    http://docs.unity3d.com/Manual/Tags.html
    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
     
  4. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
  5. herllycules

    herllycules

    Joined:
    Sep 23, 2015
    Posts:
    4
    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?