Unity alternitive to Triggered Colliders

Hey guy’s its me again,
Let me demonstrate something…

I’ve been working on my new Swarm System but i have a problem with the Collider!
if every little ship has got an collider and it’s triggered, the system will overflow…

And here is my Question: "“How can i select single units by clicking the mouse, with physics collider or is there maybe a other better solution?”
Other Question: “Can i write my own Physics in Unity?”

Waiting for Unity5’s Physics is impossible xD, i must do this on my own :stuck_out_tongue:

My other problem is to Rotate Objects with One Frame?
Every Little asteroid has got his own Script with an Update Funktion to rotate the Object Randomly on the Z Axis.
But this needs many CPU usage…maybe with Rigidbody?

Question is: “How can i make this with low CPU usage?”

-lg Alex

If you just want to select the object, and colliders are eating up too much memory, you could use Bounds.

Regarding the rotation - is there a reason that each asteroid has to handle it’s own rotation? Can you not have an asteroid handler class that keeps the full list of all asteroids, and loops through each asteroid. That way you can start to make smart decisions about perhaps not updating every asteroid on every frame. Maybe only do odd numbered asteroids on odd numbered frames or something along those lines.

Given the amount of objects you have, it probably won’t make too much of a difference but have you tried using layers and the collision matrix?
EDIT: Wilder and messier idea. It appears that ships are close together. You can try to approximate one big colliders for all of them and use guess work to see which one was damaged.
EDIT2: Building upon the above idea. Have a swarm manager that keeps track of the positions of its ships. Convert clicks to world coordinates and approximate selection with a distance check.

Maybe you could use larger colliders to activate a group of individual colliders.

1 Like

Yup like this solution better

if you wanted to avoid unity’s colliders, you could use a two dimensional KDTree to keep track of your objects and use your own raycasts on top of that.
Not sure if the trouble would be worth it.
And that would not fix the problem with having too many colliders as well, you would still have to group up your objects into bigger colliders.

A possible trick for the asteroids rotation would be not to really rotate their transform, but to use some animations. You could have a set of a few animations, and randomly select one animation and randomly scale their speed.

And for that many spaceships you should avoid the update function as much as possible, not sure what you are using, but just make sure you are using Coroutines as much as you can.

i use a complex algorithm for my Spaceship Units as you say avoid the Update function, i’m using many Coroutines :wink:

Guy’s, thank you all for helping me :wink:
I think i would use bigger Colliders to to aktive a smaler group of triggers colliders, and for the asteroids i have to find out whats the better solution… animation or one gameobject who is the manager and handles all the asteroids :wink:

-lg Alex