Jump to content
pcc

Getting markers' direction that createVehicle picks

Recommended Posts

The vehicles spawn on one of the markers in createVehicle markers array, but I how do get the particular marker chosen for that vehicle.  I want to set my vehicle direction to the same direction as the markers they spawn on.

Share this post


Link to post
Share on other sites

You can search for the nearest marker once spawned. Here my markers are mk1, mk2, mk3, mk4

 

0 = [] spawn {
  private _veh = createVehicle ["b_mrap_01_F",getpos player,["mk1","mk2","mk3","mk4"],0,"none"];
  private _marker = (allMapMarkers select {getMarkerPos _x distance2D _veh < 20} select 0);
  private _dir = markerDir _marker;
  _veh setDir _dir;
};

  • Like 3

Share this post


Link to post
Share on other sites
private _choosenMarker = selectRandom[ "mk1", "mk2", "mk3", "mk4" ];
private _veh = createVehicle[ "b_mrap_01_F", getMarkerPos _choosenMarker, [], 0, "none" ];
private _dir = markerDir _marker;
_veh setDir _dir;

Just select a random marker before hand and then spawn the vehicle at that particular random markers position instead. Then you have the choosen marker to get its direction.

Makes more sense than searching all map markers testing for their position.

  • Like 3

Share this post


Link to post
Share on other sites
On 7/4/2020 at 4:58 AM, Larrow said:

private _choosenMarker = selectRandom[ "mk1", "mk2", "mk3", "mk4" ];
private _veh = createVehicle[ "b_mrap_01_F", getMarkerPos _choosenMarker, [], 0, "none" ];
private _dir = markerDir _marker;
_veh setDir _dir;

 

 

Good. Just make sure there is enough room for the vehicle to be created in the wrong direction first, and then swung in the direction of the marker. (E.g. a truck next to a wall would be a problem).

 

To solve that i often create the vehicle 100 meters up in the air, turn it, and then put it down on the ground.

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

×