The AI is allowed to Serach for a RandomPosition and move to that Position
If it arrived, the AI is searching for another RandomPosition
The next thing is to make it possible that every Ship has got his own List or Array with all other AI Gameobjects in it.
And the last thing to do, is to check if any of this Gameobjects are in a static distance to the other Objects and then it take this Objects and do it in another List or Array.
And that’s my Question: “How can i do this or check this GameObjects with the distance or with Collider Trigger”. And my other Question: “How can i make this with High Performance… to see my Performance with this Script, check out my Pics below”.
I would give them a tag instead of searching for all game objects. The other thing you can do is wait quite a while to check distances in a coroutine. They aren’t going to be moving that fast. If you use FindObjectsWithTag, it will return an array I believe, so then you can check their distances and throw out the ones out of range. Another thing would be to make a huge collider and have it follow the player and use it as a trigger. Anything out of range should be set inactive so it doesn’t waste cpu.
Yes i could check it with a Tag, that’s the simplest way to do it… but you dont get performance when you search objects with tag…
The other thing you say’d is to wait a while in the coroutine… the problem with that is, when i’m spawning a new object the object must scan all other objects to see the others distance, because other object would be destroyed and i dont wanna have them in my List
the last thing you saying dosn’t make sense because every little ship in my world should have a CircleCollider Triggerd, the physics engine from unity would overflow :s
thanks for helping me… do you have any other ideas for me
I’ll give it a shot…
One thing I’m seeing here is that every x amount of time, each script is searching through all the objects for specific ones which I imagine would take longer the more objects there are. Why not have a script on an empty object that holds the lists you want objects to be sorted into and add or remove objects from them when each is instantiated, enabled, destroyed, or disabled. Just store a reference to that script and iterate through the desired lists instead.
I would assume it is because OnBecameVisible was not called (add a debug statement). According to Docs it only is called when a renderer becomes visible, so since the renderer is disabled (still invisible) it is not being called… Just a guess though