Jump to content
Sign in to follow this  
tryteyker

Getting the direction of an object & using setvelocity in conjunction

Recommended Posts

Guys,

I'm running into quite a problem here with setvelocity. What I'm trying to do is get an object ejected from inside a helicopter. Works well, I've set everything up, but I need checks performed when the addaction gets executed.

So far I have these checks:

           if ((speed chinook) <= 50 && (getDir chinook) <= 90) then {
           ATV setvelocity [0,-20,0];
           hint "less than 90 & low speed";
           };
           if ((speed chinook) <= 50 && (getdir chinook) > 90) then {
           ATV setvelocity [-20,0,0];
           hint "greater than 90 & low speed";
           };
           if ((speed chinook) > 50 && (getDir chinook) <= 90) then {
           ATV setvelocity [0,-20,0];
           hint "speedier than 50 but less than 90";
           };
           if ((speed chinook) > 50 && (getDir chinook) > 90) then {
           ATV setvelocity [-20,0,0];
           hint "speedier than 50 and greater than 90";
           };

Don't mind my English here, just something I set up.

Now this obviously works reasonably well, but if the chopper is moving diagonally it's not gonna work well.

An idea that just crossed my mind would be having a dozen of checks to see if the helo's moving diagonally and then use setvelocity adapted to diagonal movement but I don't think having alot more checks seems useful here.

Share this post


Link to post
Share on other sites

You can try this, I haven't fully tested it.

10 is how fast the ATV/Object is ejected

//null=[plane,vehicle,10] execvm "kickout.sqf"

_veh = _this select 0;
_thing = _this select 1;
_speed = _this select 2;

_vel = velocity _veh;
_dir = getdir _veh;
_thing setvelocity [(_vel select 0) - _speed * (sin _dir),(_vel select 1) - _speed * (cos _dir),(_vel select 2) + 1];

Share this post


Link to post
Share on other sites

//To get the atv in the right place in the chinook - you will need to add/subtract from each of the 3 elements below to get the exact position:
_atv setposATL [getPosATL chinook select 0,(getPosATL chinook select 1)+1,getPosATL chinook select 2];

//To get the heading to the rear of the chinook and ATV facing backwards is:
_atv setDir ((getDir chinook) - 180);

//To give the ATV forward velocity of 20m/sec, upward 1m/sec:
_atv setVelocity [(sin (getDir _atv))*20, (cos (getDir _atv))*20, 1];

I'm doing this with paratroopers out of a C130 and it works well (over 14 ish m/sec injures AI and players though!) - just got to get them into 2 parallel lines in the aircraft and get them to shuffle along to the back!

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

I'm actually using attachTo since it is supposed to simulate transportation of an ATV inside a Chinook (only issue there is that it's invisible when sitting inside the Chinook).

So, I don't think your method is going to work, Mattar. It is also facing backwards automatically. I will definitely try the last line of your script though.

Share this post


Link to post
Share on other sites

Ahh you are in the chinook - it's not just flying over? -

detach _atv;

then use last 2 lines of my code, that should work? - not sure what to do about the invisibility - think it's something to do with the interior of the model.

Share this post


Link to post
Share on other sites

Yup, worked out. Thanks a bunch.

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  

×