Author Topic: containerRadiusSearch Efficiency  (Read 525 times)

I need to detect the collisions of the units in my RTS.
I was gonna do a radius search in a certain area and check the units in that tiny radius.
If I have a selection of 70 units, its going to be doing this for ALL SEVENTY units.

How efficient is this function? I heard it should be avoided somewhere a long time ago.
Does it go through every object and check to see if they're in the sphere?

It would probably be more efficient to detect units that are near eachother, do a larger radius search around each group of nearby units and then use simple vectorDist logic to assign the results to different units.

Yeah 70 calls to this is not gonna be good efficiency. Can you explain what you're trying to do in more broad terms?

Yeah 70 calls to this is not gonna be good efficiency. Can you explain what you're trying to do in more broad terms?
I'm detecting collisions between the items as they dont have collision already themselves. Basically, when a unit is too close to another, I want it to stop moving in that direction as if the unit was solid. I think I'm getting somewhere though and ill post if I need more help

It shouldn't pose a problem seeing how the function runs relatively fast unless it's picking up a crapload of objects.