Jump to content
Sign in to follow this  
Joe98

How to start a soldier adjacent to a truck that appears at a random location

Recommended Posts

Place a series of markers on the map

Place a truck on the map

Select F2 group mode.

Group the truck with the markers.

Every time the mission starts, the truck will start at random in its original location or on one of the markers.

Name the truck, truck1

Now place a soldier on the map adjacent to the truck. Name the soldier blue1

In the soldier’s init type blue1 setPos (getPos truck1)

Every time the mission starts, the truck will start in a different place and the soldier will be (in theory) adjacent to it.

Except that the man finishes up under the truck dead.

How can I start the man 2 meters from the truck?

.

.

Share this post


Link to post
Share on other sites

This is untested but it should work. Paste this into blue1's init line:

modelOffset = [0,-4,0]; worldPos = truck1 modelToWorld modelOffset; [color=#333333]blue1 setPosATL [worldPos select 0, [/color][color=#333333]worldPos[/color][color=#333333] select 1, 0][/color];

What this does is use the modelToWorld command to determine a four meter offset to the left of truck1 and then setPos blue1 there. I used four meters because the offset is from the center of the vehicle, not the side, so this makes sure you are clear of the vehicle. If distance needs to be be adjusted you can change it. I think -4 puts it to the left but I cannot remember if negative is left or right so if on wrong side just make the negative number a positive number (4).

Edited by Loyalguard
Made setPoSATL work better

Share this post


Link to post
Share on other sites

Another approach would be thoe following:

in the soldier's init field put this:

_teleportstart = [this,truck1] execVM "truckteleport.sqf";

and the truckteleport.sqf:

_soldier = _this select 0; //the soldier.
_truck = _this select 1; //the truck.
_postruck = [(getpos _truck select 0) +2, getpos _truck select 1, 0] //the position where the unit will teleport to. gets the location of the truck and then set it 2 meters to the east of the truck.

_soldier setpos _postruck; //move the soldier to the position next to the truck.

not tested.

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  

×