Jump to content
pappagoat

How to setPos a set distance/direction from object?

Recommended Posts

Hi all,

 

Need a little help. I'm slowly making a static line on map click script, but am having difficulties with setpos.

 

The point of the map click is the drop zone, and I want to move or spawn an aircraft say 5000 meters east of the map click, and have it fly to a point 5000 meters west of the map click.

 

How can you do setpos + additional set distance and direction?

Share this post


Link to post
Share on other sites
Just now, pappagoat said:

Hi all,

 

Need a little help. I'm slowly making a static line on map click script, but am having difficulties with setpos.

 

The point of the map click is the drop zone, and I want to move or spawn an aircraft say 5000 meters east of the map click, and have it fly to a point 5000 meters west of the map click.

 

How can you do setpos + additional set distance and direction?

 

private _start = _dz getPos [5000, 90];

private _end = _dz getPos [5000, 270];

 

Assuming of course that _dz contains the position of the mapclick. 

Share this post


Link to post
Share on other sites

How? Math.

Pos + directionVector*distance.

DirectionVector is normalized. That means it corresponds to 1m of total distance.

1m*distance == distance.

 

With east and west it's easy. You don't even need the full vector.

East is positive on Y axis. And West is negative.

 

_position = getPos mapClick

_east = _position vectorAdd [0, distance];

_west = _position vectorAdd [0, -distance];

Share this post


Link to post
Share on other sites

Still having issues getting it to work:

 

1. How to have the rest of the script execute only after a mapclick (and not using sleep to delay it)

2. Getting errors with _ingress and _egress

Quote

 

openMap true;
sleep 1;
hint "Click on the map for location of Static Line Drop Zone.";
onMapSingleClick {"DZ1" SetMarkerPosLocal _Pos};

sleep 5;
_Pos = getMarkerPos "DZ1";

titleText ["","BLACK OUT"];
sleep 1;
openMap false;

paratrg setPos [_Pos];
doorstrg setPos [_Pos];

_ingress = _Pos vectorAdd [10000, distance];
_egress = _Pos vectorAdd [5000, -distance];

sleep 1;
plane1 setVehiclePosition [_ingress, [], 1000, "FLY"];
plane1 flyinheight 300;
plane1 doMove (_egress);

 

 

Share this post


Link to post
Share on other sites

What did you do with my code? I thought you wanted east/west. Now you got north and north, and a undefined variable.
 

Also I keep forgetting that vector commands only work with 3D positions.
 

_ingress = [_pos select 0, (_pos select 1) + distance]

_egress= [_pos select 0, (_pos select 1) - distance]

Again. east west. What you said you wanted.

 

 

 

On 17.11.2018 at 1:59 AM, pappagoat said:

execute only after a mapclick

Just put it in there

On 17.11.2018 at 1:59 AM, pappagoat said:

onMapSingleClick {"DZ1" SetMarkerPosLocal _Pos};

 

Share this post


Link to post
Share on other sites
12 hours ago, Dedmen said:

What did you do with my code? I thought you wanted east/west. Now you got north and north, and a undefined variable.
 

Also I keep forgetting that vector commands only work with 3D positions.
 


_ingress = [_pos select 0, (_pos select 1) + distance]

_egress= [_pos select 0, (_pos select 1) - distance]

Again. east west. What you said you wanted.

 


You sure about that?

 

            N(+y)
            |
            |
W(-x) ------|------ E(+x)
            |
            |
            S(-y)

 

Share this post


Link to post
Share on other sites

This worked, just need to make it so that the rest of the script only happens after the map click, at the moment I have a 5 second delay.

 

 

openMap true;
sleep 1;
hint "Click on the map for location of Static Line Drop Zone.";
onMapSingleClick {"DZ1" SetMarkerPosLocal _Pos};        //placing a DZ marker by map click on designated DZ
sleep 5;
_Pos = getMarkerPos "DZ1";

sleep 1;

DZ setpos _Pos;        // moving an invisible helipad to the DZ marker

sleep 1;
openMap false;

paratrg attachTo [DZ, [0, 0, 0] ];                  // attaching triggers already made in the mission to the invisible helipad at the DZ, so that the triggers cover the DZ area. The triggers control aircraft doors opening and triggering of paradrop script
doorstrg attachTo [DZ, [0, 0, 0] ];

 

_Pos = getMarkerPos "DZ1";                     // creating startpoint and endpoint for aircraft.

sleep 2;

_ingress = _Pos getPos [10000, 90];
_egress = _Pos getPos [5000, 270];

 

sleep 1;
plane1 setVehiclePosition [_ingress, [], 100, "FLY"];                    // moves existing aircraft into the air so that it flies across the drop zone, flying through the triggers that make its doors open and then trigger a paradrop script.
plane1 flyinheight 200;
plane1 forceSpeed 67;
plane1 doMove (_egress);

Share this post


Link to post
Share on other sites

Sorry was meant to be an easy example, but I was having so much fun I went off on a tangent and ended up with this. Hope you can pull from that what you need, specifically look at the function TAG_fnc_addDropZone.

  • Like 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

×