Jump to content
beako

How to get soldier to move to buidlingPos

Recommended Posts

The _newUnit moves to the x,y postions but not to buildingPos _index and remains partially underneath and inside the building.

_building = nearestObjects [ASLToAGL (_intersections select 0 select 0), ["Building"], 10] select 0 ; 
_newUnit Move  (_building buildingPos _index);

How do I get him to move upstairs to the designated buildingPos?

 

Share this post


Link to post
Share on other sites


_newUnit move ((nearestBuilding _newUnit) buildingPos _index);

Share this post


Link to post
Share on other sites

the old ArmA 2 script is a simple way of putting units in buildings., it still seems to work!

 

 Put it in the init of the unit you want to position;

 

this setPos (nearestBuilding this buildingPos  1); 

 

Select whatever number position you want.

 

Or for a random position in a group of buildings nearby use;

 

this setPos (nearestBuilding this buildingPos random 4);            some buildings have more/less positions available  1, 4 7, etc, whatever, if you need it to be in a specific building, place the unit right next to it.

 

for a unit to be in kneeling & stop for a while use something like.

 

this setPos (nearestBuilding this buildingPos random 4);this setUnitPos "middle";  doStop this;

 

If you need the unit to remain standing & not kneel or lie down use,

this setUnitPos "up";

Share this post


Link to post
Share on other sites

Thanks folks,

 

But the issues is the unit does not go to the position at the building. I did try nearestBuilding but that does not work and if I setPos to the buildingPos the soldier leaves and goes back down under/inside the building.

 

As per below, perhaps I have to specify the building model from CfgVehicles?

 

Notes from before the conversion:These examples will move a unit to the 1st position specified in a buildings model, in the second example - bunker1.

this move (building buildingPos 1);

this move (bunker1 buildingPos 1);

 

In the default game buildings, the buildingPos is usually right behind a window. This can make it easy to place units in the windows of buildings, by putting the unit near a building and putting this in its init field:

this setPosATL ((nearestBuilding this) buildingPos 1);

 

The location returned by buildingPos is not reliable after the player has exited and then resumed the mission. For code that is executed immediately after the mission starts there is no problem. If buildingPos locations are to be accessed during the mission when the player may have exited and then resumed, save the locations you require at the start of the mission and use these saved locations in your subsequent scripts.

 

 

Any thoughts?

Share this post


Link to post
Share on other sites

The _newUnit moves to the x,y postions but not to buildingPos _index and remains partially underneath and inside the building.

 

It's a bug. See assigned feedback tracker issue T85935

AI moving due to doMove/commandMove/moveTo script commands do not always respect the Z value of the destination. It's very frustrating, as subordinate AI ordered to move to the same positions via in game commands work perfectly.

For automated example of the bug (and many more AI building bugs), see my AI vs buildings test mission.

 

AI also seem to be more likely to move into the floor (and make other movement fails) when they are distant from the the player, see T118815

Share this post


Link to post
Share on other sites

Darn, OK thanks ceeeb,

 

I guess I cheat and setPos the unit to the roof top and have them walk from one BuildingPos to the other.

 

 

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

×