OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: UH60MG on 14 Jun 2008, 18:06:49

Title: Add a velocity [ Solved ]
Post by: UH60MG 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  :)
Title: Re: Add a velocity
Post by: Mandoble 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;
};
Title: Re: Add a velocity
Post by: UH60MG on 16 Jun 2008, 18:16:01
Just what I was looking for. Thanks.