Jump to content
Sign in to follow this  
Sexacutioner

tell if there are units under position

Recommended Posts

So this is a difficult thing to search for. I'm wondering if there is scripting command or similar to get all units around a certain position.

What I'm trying to do is spawn an unknown amount AI in helicopters, but if I don't keep increasing the X or Y position they crash into each other. I would like if the space is empty to spawn the AI there, but if there is already someone there then spawn it a bit further and so on.

I can accomplish this in a while loop if there is a command like "findEmptyPosition" or isAt(x,y,z) that can tell me if there is a vehicle already at this position. The AI will fly at different times and more are created at different times at the player control so it would be easiest to just check the area and move the position if it's occupied.

Share this post


Link to post
Share on other sites

There are a few options

first is when spawning make sure your not using the can_collide option

allows units to be spawned at the same position

veh = createVehicle ["2S6M_Tunguska",getpos this,[], 0, "can_collide"];

attempts to find an empty area

veh = createVehicle ["2S6M_Tunguska",getpos this,[], 0, "none"];

if that isn't enough the the following may help

http://community.bistudio.com/wiki/findEmptyPosition

Share this post


Link to post
Share on other sites

I ended up with a solution using nearEntities:

_currentSpawnPos=getMarkerPos "eastStartSpawn";
while {count ((_currentSpawnPos) nearEntities 70)>0} do {
_currentSpawnPos=[_currentSpawnPos select 0,(_currentSpawnPos select 1)+70,_currentSpawnPos select 2];		
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×