Home   Help Search Login Register  

Author Topic: Multiple Rappel Rope Question  (Read 592 times)

0 Members and 1 Guest are viewing this topic.

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Multiple Rappel Rope Question
« on: 13 Oct 2004, 03:00:34 »
Hey All-

My question:

I want to have four ropes coming out of a helo during a rappel.  The problem I have encountered is making it so that the ropes move with the change in the helicopters direction.  For the moment they just stay where ever they were created on the x,y,z plane and don't take into account that the helo's plane may not be due north.  Here is the script.

Quote
@startRope
_chopper = _this select 0

_rope = "SNYRope" createVehicle [0, 0, 0]

#start
_rope setpos [(getpos _chopper select 0) + 1 , (getpos _chopper select 1) + 1 , (getpos _chopper select 2) + 1 ]
~0.01
?ropeUp:goto"end"
goto "start"

#end
deletevehicle _rope
exit

Any Suggestions?

Blip  :joystick:
« Last Edit: 13 Oct 2004, 05:29:42 by Blip »
...NIGHT WALKER....

Kammak

  • Guest
Re:Multiple Rappel Rope Question
« Reply #1 on: 13 Oct 2004, 04:18:43 »
I must be missing something, because the script above doesn't seem to care what direction the helo is facing, as the rope is positioned exactly at the helo's pos, 1 meter above it. ???

Is the rope supposed to be offset to one side or the other?

Right now (from the script) I'm imagining the rope comes out the center of the helo and runs through the cabin...is that what it looks like?

Or does the object you are using for the ropes have an offset built-in to the 3d model?

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Multiple Rappel Rope Question
« Reply #2 on: 13 Oct 2004, 05:32:43 »
Hey Kammak-

Sorry about that, I changed the script to about where I want the first rope to be.  

Basically, I want four ropes each at a different position coming off the helo.  This is only a script for one of those ropes.

Quote
I must be missing something, because the script above doesn't seem to care what direction the helo is facing

This is what I am trying to figure out.  I am not sure how to script it so that the rope is facing the same direction.  I tried using setdir and getdir but couldn't get it to work.  Thats why I turned to the forum.

Blip  :joystick:
...NIGHT WALKER....

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Multiple Rappel Rope Question
« Reply #3 on: 13 Oct 2004, 05:46:45 »
I made a handy function that finds position relative to an objects direction.  The header explains how to use it.  Here it is:

Code: [Select]
/*---------------------------------------------------------------
AngDirDisOff function by Raptorsaurus

Returns the positional components required to place an object relative to
another object (the reference object) at a specified angle relative to the
reference object's postition, in a specified direction relative to the
object's current direction and at a specified distance from the reference
object.

The required info passed to this function is:

- Object name
- desired angle (90 [straight up] to -90 straight down]
- desired direction (0 to 360 or 180 to -180)
- distance


Example:

_obj = _plane1
_ang = -30
_dir = 270 (or -90)
_dis = 50

_Pos = [_obj,_ang,_dir,_dis] call AngDirDisOff

_object2 setPos _Pos

This will set the _object2 at a position 30 degrees below _plane1's current
position, to the left side of_plane1 (-90 or 270), at a distance of 50 m.

Initialize this function by putting this in your init.sqs:
AngDirDisOff = preprocessFile "AngDirDisOff.sqf"
---------------------------------------------------------------*/

// declare private variables
private ["_obj","_dir","_ang","_H","_dis","_X","_Y","_Z","_Objdir","_Objpos"];
private ["_ang1","_ang2","_offang"];

// get the parameters

_obj = _this select 0;
_ang = _this select 1;
_dir = _this select 2;
_dis = _this select 3;

// make sure _dir is valid value

if (_dir > 360) then {_dir = _dir - 360};
if (_dir < 0) then {_dir = _dir + 360};
if (_dir == 360) then {_dir = 0};

_Objdir = getDir _obj;
_Objpos = getPos _obj;

//Find relative directional offset

_ang1 = _Objdir;
_ang2 = _dir;
if ((_ang1 - _ang2) > 180) then {_ang2 = _ang2 + 360};
if ((_ang2 - _ang1) > 180) then {_ang1 = _ang1 + 360};
_offang = (_ang1 + _ang2);
if (_offang > 360) then {_offang = _offang - 360};

// calculate vertical position component

_Z = (_Objpos select 2) + _dis * Sin _ang;

// calculate horizontal distance component

_H = _dis * Cos _ang;

// calculate position components in horizontal plane

_X = (_Objpos select 0) + _H * Sin _offang;
_Y = (_Objpos select 1) + _H * Cos _offang;

// new position array to position offset object

[_X,_Y,_Z]

If you put this function and a setpos command in a low delay script loop, the rope will change position as the helocopter rotates and moves.  You will have to play around with the values to obtain the optimum position for each rope, but once you get the right values you can move and rotate the helo, and the ropes will follow.

Enjoy!

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Multiple Rappel Rope Question
« Reply #4 on: 13 Oct 2004, 05:55:21 »
I also did this function which might suit you better for this application.  This one also works relative to the reference object's direction.  This one requires x, y, z offset parameters instead of angle and distance parameters.  Here it is:

Code: [Select]
/*---------------------------------------------------------------
SetObjPosObj function by Raptorsaurus

This function sets an object relative to another object but offset from that object
according to user defined parameters.  It will also return the new position.
The required info passed to this function is:

Reference object name
The object to be placed name
Front/Back offset     (positive to have object placed in front, negative to place behind)
Left/Right offset     (positive to have object placed to right, negative to place to left)
above/below offset    (positive to have object placed above, negative to to place below)
               
Example:

_refobj = _car
_plcobj = _aaguy
_offFB = -2
_offLR = -10
_offAB = 5

_pos = [_refobj,_plcobj,_offFB,_offLR,_offAB] call SetObjPosObj

This will put the _aaguy 2 meters behind the _car, 10 meters to the left of the _car
and 5 meters above the _car.  The _pos will be an x,y,z array for the _aaguy's position.


Initialize this function by putting this in your init.sqs:
SetObjPosObj = preprocessFile "SetObjPosObj.sqf"
---------------------------------------------------------------*/

// declare private variables
private ["_Refpos","_x","_y","_z","_Refdir","_offFB","_offLR","_offAB","_leadX","_leadY"];
private ["_leewX","_leewY","_pos","_refobj","_plcobj"];

_refobj = _this select 0;
_plcobj = _this select 1;
_offFB = _this select 2;
_offLR = _this select 3;
_offAB = _this select 4;

_Refdir = getDir _refobj;
_Refpos = getPos _refobj;

_x = _Refpos select 0;
_y = _Refpos select 1;
_z = (_Refpos select 2) + _offAB;

// Setup _plcobj position relative to _refobj

_leadX = (_offFB * Sin _Refdir);
_leadY = (_offFB * Cos _Refdir);
_leewX = (_offLR * Sin (_Refdir + 90));
_leewY = (_offLR * Cos (_Refdir + 90));

_pos = [(_leadX + _leewX + _x),(_leadY + _leewY + _y),_z];
_pos

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Multiple Rappel Rope Question
« Reply #5 on: 13 Oct 2004, 18:33:35 »
Hey All-

Raptorsaurus that was just what I needed.  The rope is now moving perfectly with the helicopter.

However, now I have hit another bump.  To make it so the unit slid down the rope instead of missing it, I created the rope as a global varibale in the init.sqs.  I called it rope1.

Now when I call on the rope I use rope1 and the .sqf file and that works great.  I also wanted to set the rappeler's position such that they rappeled down the rope.  Usually the rappel script calls for the position of the helo since the rope usually is coming from that same position.  So add a drop factor and the guy drops down the rope.  Well, I switched it so that the rappeler calls for the position of rope1 while he is sliding down the rope.  I figured this would work.  It's not.  The dude still slides down right below the helo not where rope1 is.

Attached is the rappel script I have been working with.

Blip  :joystick:
...NIGHT WALKER....

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Multiple Rappel Rope Question
« Reply #6 on: 13 Oct 2004, 23:57:59 »
Maybe you can try and use the function with the guy rappelling and the rope.  If you then adjust the values you can get him to start in the correct position.  Also, The second function I sent not only places the rope, but is also returns the position of the rope, you can use this to help trouble shoot why the guy is not positioned correctly.