Jump to content
Sign in to follow this  
splatsh

Problem with attachTo

Recommended Posts

I am using some of this code:

http://forums.bistudio.com/showthread.php?t=77397&highlight=BIS_fnc_supplyDrop

By Tajin

This is how my code look like now.

_spawntype = "HMMWV_M2";

_bpos = C1 ModelToWorld [0,-12,-5.5];

_bomb = _spawntype createVehicle _bpos;
_bomb setpos _bpos;
_bomb setDir direction _bpos;
_chute = "ParachuteMediumWest" createVehicle getpos _bomb;
_chute setpos (_bomb ModelToWorld [0,0,3]);
_bomb attachTo [_chute,[0,0,0]];
sleep 0.05;

Ok, I have a C-130J named C1 on my map who is flying.

When my code is in action, there is a spawn of a HMMWV_M2 and its moving towards the ground. But now Chute is there, I cant get this chute to spawn and attachTo the car.

Whats wrong?

Share this post


Link to post
Share on other sites

I think this line will cause it to exit the script with an error, at least it did when I tried it a few days ago.

_bomb setDir direction _bpos;

Share this post


Link to post
Share on other sites

_bpos is a position, so it doesn't have a direction.

Share this post


Link to post
Share on other sites

If I remember right I tried that junker and it will work but it won't line the vehicle up with the aircraft.

I don't think I ever did get it lining up for some reason.

Share this post


Link to post
Share on other sites

_spawntype = "HMMWV_M2";

_bpos = C1 ModelToWorld [0,-12,-5.5];

_bomb = _spawntype createVehicle _bpos;
_bomb setpos _bpos;
_bomb setDir direction C1;
_chute = "ParachuteMediumWest" createVehicle getpos _bomb;
_chute setpos (_bomb ModelToWorld [0,0,3]);
_bomb attachTo [_chute,[0,0,0]];
sleep 0.05;

If u mean this?

That did not work. =(

Share this post


Link to post
Share on other sites
If I remember right I tried that junker and it will work but it won't line the vehicle up with the aircraft.

I don't think I ever did get it lining up for some reason.

Try lining up the chute instead :)

Edit: heres a version i did

_plane = _this select 0
_dir = Direction _plane

#spawnit
_truck = "LAV25" createvehicle getpos _plane
_truck setdir _dir
_truck setpos [getpos _plane select 0, getpos _plane select 1,(getpos _plane select 2) -10]
~0.1
_chute = "ParachuteBigWest" createvehicle getpos _truck
_chute setpos [getpos _truck select 0, getpos _truck select 1,(getpos _truck select 2) -0]
_chute setdir _dir
~0.1


_truck attachTo [_chute,[0,0,0]] 

_vel = Velocity _plane;
_speed = -50;
_chute setvelocity [(_vel select 0)+(sin _dir* _speed),(_vel select 1)+(cos _dir* _speed),(_vel select 2)]
_truck setvelocity [(_vel select 0)+(sin _dir* _speed),(_vel select 1)+(cos _dir* _speed),(_vel select 2)]
Exit

Edited by Junker

Share this post


Link to post
Share on other sites

You were right about the Chute Junker worked ok.

I also like the velocity version as it makes it look less faked.

Share this post


Link to post
Share on other sites

Good idea about the velocity.

The setvelocity for the truck should be obsolete though, as it's already attached.

Oh, just a sidenote: If you dont wan't to use sin/cos you could always divide and multiply the speedvectory by the total speed.

like this:

_vel = Velocity _plane;
_spd = speed _plane;
_targetspeed;
_thing setVelocity [(_vel select 0) / _spd * _targetspeed,(_vel select 1) / _spd * _targetspeed,(_vel select 2) / _spd * _targetspeed]

Share this post


Link to post
Share on other sites

I've also added a bit and this can be just tacked on at the end.

_ndir   = 0;
_ndir   = getdir _chute;
_speed  = (random 0.02)+0.06;
_rotdir = (random 4)-2;

while {((getpos _truck select 2) >2)} do
{
_ndir = _ndir + _rotdir;
	_chute setdir _ndir;
		sleep _speed;
};
detach _truck;
_chute setvelocity [(_vel select 0)+(sin _dir* _speed),(_vel select 1)+(cos _dir* _speed),(_vel select 2)];

To vehicles it adds a bit of rotation on the way down and unattaches the chute from the truck a few feet off the ground so the vehicles don't sink in the ground. It also adds a bit of velocity to the chute to get it clear of the truck and stops it staying vertical for a while.

I'd like to add a bit of dust next when it lands.

Share this post


Link to post
Share on other sites

Ew, looks like I threw you guys a bone and you're making a nice steak out of it. ^^

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  

×