So here is what I’m trying to Do. I have a bunch of different AI roaming around my scene where few are unfriendly and few are friendly. So when I click on an unfriendly one he turns friendly in achieving this by changing the tag of them. I took these characters into the list and stored them. Now I want help where every character in my world/ scene if they have a friendly tag on them I want the game to load next level/scene.
I tried this by doing listname.Count == gameObjects.tag == "Friendly" by the syntax is not a proper one. So yeah need help with this.
Thanks in advance
loop through all Ais check if they are friendly, tally it up, compare.
listname.Count == gameObjects.tag == “Friendly”
listname.Count is an integer, that is how many elements are in the list. gameObjects.tag is a string, you can’t assign or compare different variables…
try:
public void CheckFriends(){
int friends=0;
foreach(GameObject go in listname){
if(go.compareTag("Friendly"))
friends++;
}
if(friends==listname.Count)
LoadLevel();
}
Hi,
Everytime you make an unfriendly into a friendly you can call the method that counts the number of unfriendlies remaining or fire an event to do that.
So you click an unfriendly, converting it to friendly, then something like onConvertToFriendly is fired and checked by your gamemanager or whatever holds the list of unfriendlies - it then counts how many are in the list, and if it’s zero, you load the next level.