Plane physics

Posted By: BastovBros

Plane physics - 09/24/09 20:55

I have a plane, it flies if I press "W" (simple c_move movement), rolls and tilts, if I move the mouse. But I have a problem: I wanna "teach" it to accelerate and take off. First question: How to put it on the ground? I wrote a code:
Click to reveal..
...trace_to_ground = c_trace(my.x, vector(my.x,my.y,my.z-1000), IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX);
if(trace_to_ground>1){my.z = -275;}...

So now it stand on the ground, but only in a particular spot(since the terrain is not flat) and I cannot stick it to the terrain with a c_trace. I decided to add physics, standard GS functions phent_settype, phent_gravity, phent_mass, etc. Now it stands on the ground but it does not react to pressing any buttons. I read somewhere that c_commands do not work with physics. So I added ...phent_addforcelocal (me, vector(forward,0,0), nullvector); if(forward <5000)//limitation of accelreation// forward +=20;... to the "key_w". Now it can speed up to a huge speed and than suddenly stops and stands still(I think after reaching the 5000 speed) and noting can move it + it is uncontrollable. Second question: how to apply movement physics properly (any tutorial would be helpful) and avoid all this bugs or whatever it is, and make its speed become steady and equal 5000 when it reaches this speed? Since it is a plane, it should take off, fly up, but can't fugure out how to do this. I tried to lower the mass and gravity force as it accelerates so that they both equal 0 when it reaches certain "taking off" speed (approximately 2500) but it changed nothing, actually had no effect at all. I cannot add a vertical acceleration (like for a helycopter) since this does not satisfy plane controls... I have to raise it up at first (tilt it) since it always flies forward. So the third question: How to make my plane take off so that it does not contradict with the mass and gravity force?
I know about Newton physics, but I do not know how difficult it is to accomplish this all with it. Genrally, I just whant to understand the principle of the plane motion (it should behave like a car when it is on the ground and then be able to take off when it has proper speed)...Sorry for the long post....
Posted By: xXxGuitar511

Re: Plane physics - 10/04/09 04:16

You don't want to try and use a physics engine for flight simulations, they never come out right. You'll have much better results programming your own physics. If I had access to my computer I'd share my code (at a friends). Just use some reverse trig (asin; acos) based on the planes angles to calculate your forces (lift; drag; etc).
© 2024 lite-C Forums