Yeah, just wanting to know if it’s possible to somehow get a random transform from a certain layer.
i need this for my AI enemies, so that they can chose to look at and chase after any of the AI on another team and vice-versa.
Yeah, just wanting to know if it’s possible to somehow get a random transform from a certain layer.
i need this for my AI enemies, so that they can chose to look at and chase after any of the AI on another team and vice-versa.
Something like
var allAIs : Array() = FindObjectsOfType(AI);
target = allAIs[ parseInt( Random.value * (allAIs.length-1) ) ];
?
You might want to create your ‘allAIs’ or "allRedTeamAIs’ or whatever arrays at Start(), then just update them whenever you add/remove an AI to avoid calling the expensive FindObjectsOfType function all the time.
cool thanks, that looks pretty good.
i also found this function;
targetAI = GameObject.FindWithTag("Red_AIs").transform
I’ll give em both a go ![]()