Search Unity

Resolved Add Object to Targetgroup

Discussion in 'Cinemachine' started by svenvanh, May 28, 2020.

  1. svenvanh

    svenvanh

    Joined:
    Nov 29, 2019
    Posts:
    51
    I want to make it so every object with the tag "player" gets added to the target group.
    how can I make that?
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You have to write a script that gets all gameobjects with "player" tag and then adds these to your target group.
    For example:
    Code (CSharp):
    1. GameObject[] players = GameObject.FindGameObjectsWithTag("player");
    2. foreach (GameObject player in players)
    3. {
    4.       targetGroup.AddMember(player.transform, weight, radius);
    5. }
     
    Gregoryl likes this.