gc8 970 Posted June 6, 2019 Hi I'm trying to use isFlatEmpty to check if position is free for spawning an AI unit but it doesn't work. The pos is never free according to isFlatEmpty when it actually is. Here's my test code: sleep 0.1; _a = getdir player; // For testing purposes get dir from player's dir _pos = b getPos [5, _a]; // b is the small bunker, get pos behind the bunker _pos set [2,0]; _fePos = _pos isFlatEmpty [0.1, -1, -1, -1, -1, false, objnull]; if(count _fePos > 0) then // Pos free? { _g = createGroup west; _g createUnit ["B_crew_F", _fePos, [], 0, "FORM"]; } else { systemchat "NO ROOM"; player setpos _pos; // If not free move player to the pos for visual confirmation }; It always prints "NO ROOM" when there is room... What could be wrong? thx! Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 6, 2019 why using isflatempty? createUnit already seeks for a free position if last parameter is FORM or NONE. 2 Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted June 6, 2019 7 minutes ago, sarogahtyp said: why using isflatempty? createUnit already seeks for a free position if last parameter is FORM or NONE. He's looking for a spot behind a bunker, no idea if he intends to spawn stuff there or simply wants to setPos the units. 24 minutes ago, gc8 said: It always prints "NO ROOM" when there is room... What could be wrong? thx! Try increasing the distance. 5m might not be enough since it's calculating from model center [0,0,0] as far as I know. Seeing how macroscopically inaccurate the boundingboxes are I wouldn't be too surprised. Outer frame: boundingBox Inner frame: boundingBoxReal Might need a boundingBoxForReal command... Cheers 1 1 Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 12 minutes ago, sarogahtyp said: why using isflatempty? createUnit already seeks for a free position if last parameter is FORM or NONE. What happens if it cant find free pos? createUnit fails? Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 6, 2019 it should spawn on nearest free position Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 1 minute ago, Grumpy Old Man said: Try increasing the distance. My understanding from the wiki is that the minDistance should be the object size your trying to fit in. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted June 6, 2019 Just now, gc8 said: My understanding from the wiki is that the minDistance should be the object size your trying to fit in. I meant the distance for the getPos command. Cheers Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 1 minute ago, sarogahtyp said: it should spawn on nearest free position Ok well that's good to know but while in my test code I create the unit I actually have the unit already created in my mission where I plan to use this code. I'm just moving the unit to free pos Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 1 minute ago, Grumpy Old Man said: I meant the distance for the getPos command. Oh right, I tried few numbers there without any luck. I actually first tested this code in VR map where it worked. But when I run this on tanoa it doesn't work... Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 6, 2019 there is another command for this. something like vehiclePosition but im on mobile edit: its setVehiclePosition 1 Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 2 minutes ago, sarogahtyp said: there is another command for this. something like vehiclePosition but im on mobile setVehiclePosition. Guess I'm gonna use that then Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted June 6, 2019 4 minutes ago, gc8 said: Oh right, I tried few numbers there without any luck. I actually first tested this code in VR map where it worked. But when I run this on tanoa it doesn't work... What bunker did you mean in your first post? Depending on position some vegetation might also interfere, hard to tell without further details. Cheers Share this post Link to post Share on other sites
gc8 970 Posted June 6, 2019 5 minutes ago, Grumpy Old Man said: What bunker did you mean in your first post? Depending on position some vegetation might also interfere, hard to tell without further details. Cheers This : https://imgur.com/a/ABrhGuY Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 6, 2019 Hello there gc8 ! 4 hours ago, gc8 said: isFlatEmpty to check if position is free for spawning an AI unit Why to check the unit's position , since you are probably checking this when you are spawning the bunker ? or not ? Share this post Link to post Share on other sites
ZaellixA 383 Posted June 6, 2019 Hey there gc8. I believe the guys here provided some alternatives, so I am just gonna make a short comment. If you check the docs you'll see Killzone_Kid's comments at the bottom of the page. He suggests the use of findEmptyPosition command because isFlatEmpty uses the bounding box (see Grumpy Old Man's post above) and some objects (Killzone_Kid mentions "Land_HighVoltageColumnWire_F" for example) can have very big bounding boxes. Also in the comment, you can find a suggestion of a utility function that uses both commands. Else, you could just use the config name of the bunker in the ignoreObject argument (last argument) of the isFlatEmpty command (not tested). Hope some of the proposed solutions will solve your problem. If not, don't hesitate to ask for more help. EDIT: Hehe, the comment was not so short in the end 😅. 3 1 Share this post Link to post Share on other sites
gc8 970 Posted June 7, 2019 I'm using the setVehiclePosition. it seems to find proper position 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted June 7, 2019 On 6/6/2019 at 4:57 PM, gc8 said: in my test code I create the unit I actually have the unit already created in my mission where I plan to use this code. I'm just moving the unit to free pos what do we learn from this? one should post original code in forum but not some pseudo stuff... if u would have done it that way then you would have got the solution with the first answer. 3 Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 9, 2019 On 6/6/2019 at 3:53 PM, Grumpy Old Man said: Might need a boundingBoxForReal command... Or you can add 0 in front of the command 1 Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted June 12, 2019 On 6/9/2019 at 11:11 AM, killzone_kid said: Or you can add 0 in front of the command Well indeed, added in 1.92, good to know. Cheers Share this post Link to post Share on other sites