Home   Help Search Login Register  

Author Topic: Add a velocity [ Solved ]  (Read 1217 times)

0 Members and 1 Guest are viewing this topic.

Offline UH60MG

  • Members
  • *
Add a velocity [ Solved ]
« on: 14 Jun 2008, 18:06:49 »
Suppose I want to add a velocity to a flying aircraft with the SetVelocity command. I want the velocity to be in direction A degrees from the centre of the aircraft and the magnitude to be B. How would I go about doing this?

Basic maths I know but I'm lazy  :)
« Last Edit: 16 Jun 2008, 18:16:14 by UH60MG »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Add a velocity
« Reply #1 on: 14 Jun 2008, 23:41:53 »
I understand you want to keep a constant horizontal velocity without climbing/diving:
Code: [Select]
// velocity is in m/s
_vel = 30;
_dir = 180;
while {true} do
{
   _vehicle setDir _dir;
   _vehicle setVelocity [sin(_dir)*_vel, cos(_dir)*_vel, 0];
   Sleep 0.005;
};

Offline UH60MG

  • Members
  • *
Re: Add a velocity
« Reply #2 on: 16 Jun 2008, 18:16:01 »
Just what I was looking for. Thanks.