# Help with aircraft movement (wrong speed etc)

This topic is 1823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, i have a problem with thrust force, speed, and overall movement (which is connected to the speed)

So i want to simulate F/A-18.

i have some constants:



const float             full_thrust_force = 156.0f * 1000.0f; // Newtons (two F18 engines)
const mass = 14500.0; //kilograms

I must also tell you that i calculate aircraft velocity after every plane 'movement' frame

====

Please see video. [the model is not scaled to real dimensions)

The first thing is takeoff. (i didin't include firction between wheels and airfield yet but it shouldn't be the main bug)

As you can see model reaches 100 m / s in a matter of seconds, And i am not quite sure why lol. (maybe thurst is too big its 200% with afterburner ;]) well thing is i dont know how much thrust afterburner can provide. (so i decided to make it 200% as it is in some flight sims)

WIth 100% thurst it takes more than 1 minute to 'liftoff'

heres a code where all magic takes place. hope you will point me into right direction.



void __fastcall TVehicle::ProcessFrame()

{

Gather_All_INFO();

AIRLIERON_LEFT->Frame_tick();

AIRLIERON_RIGHT->Frame_tick();

ELEVATOR_LEFT->Frame_tick();

ELEVATOR_RIGHT->Frame_tick();

RUDDER_LEFT->Frame_tick();

RUDDER_RIGHT->Frame_tick();

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

double l;

timin->stopTimer();

l = timin->getElapsedTime();

float dt = float(l); //get elapsed time in seconds

timin->startTimer();

if (dt <=0 ) return;

t3dpoint wind_direction; wind_direction.x = 1.0f; wind_direction.y = 0.0f; wind_direction.z = 0.0f;

float Front_force = Throttle_to_force( Throttle ); //thrust force val

float Q = eGForce * mass; // gravity force val

ThrustForce_vec = YPRangle.rf; //thrust force direction

t3dpoint frontf = ThrustForce_vec;

pos_from_plane_to_planet_center = vectorAB(pos, zero);

GForce_vec = Normalize( pos_from_plane_to_planet_center ); //g force direction

//drag coeff * density * v^2/2 * A

DragForce = reverse_point(ThrustForce_vec);

DragForce = vector_multiple(DragForce, 0.260f * 1.2250f * ((V * V) / 2.0f) * 10.420f);

//======================================================================================================

//======================================================================================================

// THE PITCH CASE (MOVE IT TO PROPER SECTION OF CODE)

//======================================================================================================

//======================================================================================================

float elevationangle = ELEVATOR_LEFT->GetAngle() * 17.5f; //17.5 is the max degree that elevator can reach

float elevator_drag_force = 1.20f * 1.2250f * ((V * V) / 2.0f) * Abs(elevationangle) * 13.2040f;

float leverlen = 8.50f;// n3ddistance(pos,ELEVATOR_LEFT->model->CENTER_POINT); // half from 17 meters lets say

elevator_drag_force = elevator_drag_force * 2.0f; //two elevators present

/************MATH****************

v = w * r

w = (r x v) / |r|^2 = alpha / t

l = m * r^2

T = m*r^2 * alpha

w x F = m*r^2 * alpha(acceleraton)

alpha = r x F / m * r^2

alpha = r*F*sin(beta) / m * r^2

after half year i started to read my notes, i don't get them.

***********MATH******************/

float alphaangularity = ((leverlen * elevator_drag_force) * sin(elevationangle*imopi) ) / (mass * leverlen*leverlen);// elevator_drag_force*elevator_drag_force);

float angvel = alphaangularity * dt;

YPRangle.pitch(cos(angvel*imopi),sin(angvel*imopi));

YPRangle.DoRotation();

//float angpos =

// alphaangularity is angle acceleration

//elevators drag force in 90* degrees

//======================================================================================================

//======================================================================================================

//======================================================================================================

//======================================================================================================

t3dpoint Lift_force;

GForce_vec = vector_multiple(GForce_vec, Q);

ThrustForce_vec = vector_multiple(ThrustForce_vec, Front_force);

result_force = GForce_vec + ThrustForce_vec + DragForce;//add forces

interia_momentum = result_force;

//divide vector by float

Acceleration = result_force / mass; // a = F / m

//At sea level and at 15 °C according to ISA (International Standard Atmosphere), air has a density of approximately 1.225 kg/m3

vel = vel + (Acceleration * dt);

pos = pos + (vel * dt);

V = n3ddistance(pos,old) / dt;

old = pos; //save position

}


Edited by ___

##### Share on other sites

By just looking at your video it seems that your thrust vector doesn't update when the orientation of the aircraft updates. Which in turn causes the velocity and direction vector to be wrong, thrust should be applied along the direction the aircraft is pointing.

##### Share on other sites
ThrustForce_vec = YPRangle.rf; //thrust force direction (the aircraft direction itself)
float Front_force = Throttle_to_force( Throttle );
ThrustForce_vec = vector_multiple(ThrustForce_vec, Front_force);

result_force = GForce_vec + ThrustForce_vec + DragForce;//add forces

then

Acceleration = result_force / mass; // a = F / m
vel = vel + (Acceleration * dt);
pos = pos + (vel * dt); <-Well it is all there maybe this is the problem but this is the main inertia


, even after i corrected the pitch rotation (that i called in the middle of the code) now it's called before setting thrust force vector. the result is still the same.

I still have a problem with speeding this f18 from 0 to 400 Km/h in a few seconds. - maybe engines with afterburner turned on (when vehicle is not moving) need time to push it with full power? (156.0f * 1000.0 N)

Edited by ___

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634071
• Total Posts
3015340
×