I'm trying to do the camera stay between two objects wich is nearest. I added the group target cinemachine, but i want to do to nearest object, on player range I tryed to AddMember in script But when i started, he add the objects a lot times because of "InvokeRepeating" And when i left the range, he dont remove those objects on group I need help, there a way more easier to do this ? or fix this ? -I'm sorry about my bad english
Don't add it if it is already a member. You can also consider putting all the nearby enemies into the group, and adjusting their weights as a function of distance, so that nearer targets will be given more significance (targets with 0 weight are ignored). That way, if 2 enemies are equally near, they will both get focus, and you will avoid jitter in the case where the nearest enemy alternates from one to the other.
The last question, sorry. How do i RemoveMember after the first parameter, like this, remove all Transforms after the Player?
group.m_Targets is just an array. Maybe the simplest and most efficient thing for you to do is to clear it and re-add all required targets every frame. Something like: Code (CSharp): List<CinemachineTargetGroup.Target> targets; // pseudo-code targets.Clear(); targets.Add(player) for each enemy { targets.Add(enemy) } group.m_Targets = targets.ToArray()