Jump to content
Sign in to follow this  
bigpickle

Spawn Object with Velocity?

Recommended Posts

Is it possible to create an object and set its facing direction, and give it some velocity

My reason for asking is on a waypoint for an A10 (_myplane) i do this small script via exc VM

//null=[_myplane] execvm "GBU.sqf";

       _myplane = _this select 0;

_pos = position _myplane;
       _GBU = "Bo_Mk82" createVehicle [0, 0, 0];
_GBU attachTo [_myplane]; 
_GBU setpos [(_pos select 0), (_pos select 1), (_pos select 2)-2];
detach _myplane;

sleep 20;

My bombs spawn as i want them to but, they dont face the direction of the planes travel and the just fall without any forward velocity :(

Edited by Bigpickle

Share this post


Link to post
Share on other sites

wow that was quick thanks Kylania :)

---------- Post added at 04:47 PM ---------- Previous post was at 04:26 PM ----------

//null=[_myplane] execvm "GBU.sqf";

       _myplane = _this select 0;

_pos = position _myplane;
       _GBU = "Bo_Mk82" createVehicle [0, 0, 0];	
_GBU attachTo [_myplane]; 
_GBU setpos [(_pos select 0), (_pos select 1), (_pos select 2)-1];
      _vel = velocity _myplane;
      _dir = direction _myplane;
      _speed = 10; comment "Added speed";
      _GBU setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

detach _myplane;

sleep 20;

Does this appear to be doing what i'm asking?

Edited by Bigpickle

Share this post


Link to post
Share on other sites

That should make your bomb fly 10m/s faster than your plane in the direction the plane was moving. I'm not sure if that'll translate into a "bomb falling" arc though. It might. :)

I know there's been "how to fake a bomb run" scripts in the editing forums before which included the math for this, I'll poke around and try to find one.

Share this post


Link to post
Share on other sites

hmm well it fell in the wrong direction and certainly didnt appear to fly faster than the plane or in the direction it was moving. Although I can change that by having the plane always come in from South to North.

Only problem there is it then needs to be real time incase the plane has to move to avoid collison.

I really appreciate the help.

Edited by Bigpickle

Share this post


Link to post
Share on other sites

Using my named aircraft i.e _myplane does this below appear correct as i could get it to work, no bombs fell :o

//null=[_myplane] execvm "GBU.sqf";

           _myplane = _this select 0;	

	    _bomb = "Bo_Mk82" createvehicle [getpos _myplane select 0,getpos _myplane select 1,3000];
	    _bomb setpos [getpos _myplane select 0,(getpos _myplane select 1)-4,(getpos _myplane select 2) -2];
	    _bomb setdir getdir _myplane;

		_bomb setVelocity [((velocity vehicle _myplane) select 0)/3, ((velocity vehicle _myplane) select 1)/3,-30];
		_bomb2 = "Bo_Mk82" createvehicle [getpos _myplane select 0,getpos _myplane select 1,3000]; 
		_bomb2 setpos [getpos _myplane select 0,(getpos _myplane select 1)+4,(getpos _myplane select 2) -2];
		_bomb2 setdir getdir _myplane;
		_bomb2 setVelocity [((velocity vehicle _myplane) select 0)/3, ((velocity vehicle _myplane) select 1)/3,-30];

	sleep 0.2;

Share this post


Link to post
Share on other sites

_myplane is a local variable, so you shouldn't really name your plane that. the trigger shouldn't have even let you type that out really.

Your code works just fine though. See the demo here. Just wait for the C-130 to fly over head.

Share this post


Link to post
Share on other sites

Thank you Kylania, its working now, guess i forgot to change something somewhere maybe. You have been a great help mate.

Edited by Bigpickle

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  

×