Advertisement

Fixing the increating momentom effect.

Started by February 05, 2003 09:43 PM
15 comments, last by Xero-X2 22 years ago
Ok I finally need a solution to the ever increasing momentom problem. If I have a space ship it has some fancy engine and if it fires once it makes a ship with no momentom have some. ok but what happens if it burns continuesly does it add, No... So how do you mange to keep the momentom of the space craft to the correct amount? This can''t be solve by just saying take the mag of the momentom vector and see if its out of the speed range. then if it is resize it or something like that it has to really work... Could some one explain how something like thise would work? Situation is space. Plz help me with this the problem has been plagueing me for a while now. thanks.
"I seek knowledge and to help those who also seek it"
quote:
If I have a space ship it has some fancy engine and if it fires once it makes a ship with no momentom have some. ok but what happens if it burns continuesly does it add, No...

Momentum is the product of mass and velocity. For the ship to accelerate, the velocity has to increase, and so will the ship's momentum. Assuming constant mass, the only way momentum won't increase is if the velocity is constant or decreasing. The engine's job is to accelerate the ship, so if it burns continuously, that's exactly what it will do

[edited by - Zipster on February 5, 2003 11:46:42 PM]
Advertisement
But how would I handle it correctly in a game? if anything how would you handle the acceleration of the ship like this?
"I seek knowledge and to help those who also seek it"
What I would do is:

When the engine is on it imparts a force F on the spacecraft per second ( or frame depending on how your game works). The ngiven the mass M of the ship we get the accelleration A = F/M. From that each frame we add this A to the velocity V and the momentum is simply MV. Doing everything by forces is usually your best approach to this kind of thing
Xero you seem to think that the ship won''t continue accelerating if the engines stay on.... but it will. There''s no problem to fix.
No the problem I have is how to apply to forces. If I were to do it the way I was doing It, it would ADD the forces per second so if you had the engines on at full every second your speed would double! that is bad, unless that really happens which I doubt because according to my knowlege your fastest speed is the speed caused by the most powerful force for instance in a 1d situation.

*-------------------------

I hit the star thingy at the end at 2KM and it moves at 2KM.

then I hit it again at say this stage at 8KM.

-----*--------------------

now the ball will travel endlessly at 8KM not at 8+2KM it moves in the amount of the most powerful force in that direction Correct?

I hope you see what my problem is.

Ok if I store it in forces like every second I keep track of all current forces Correct? then I take that and what do I do with all these forces If I where to apply those a current time the only thing missing would be "AN OBJECT IN MOTION TENDS TO STAY IN MOTION" so if you turn the engine off nolonger would I move forward. So how do you suggest how I handle the momentom of the object and velocity? thanks.

[edited by - Xero-X2 on February 6, 2003 4:24:31 PM]
"I seek knowledge and to help those who also seek it"
Advertisement
you should just learn some basic physics stuff. it will help your infinitely with your problem.

F = ma (Force = mass * acceleration
this means that every force you apply increases your acceleration. if you apply a force of 2N for a while then later apply a force of 8N for another while your resultant velocity will be greater than if you had one or the other applied by itself

s(t) = 1/2 * a * t^2 + v * t + s
s(t) = position at time t

a = current acceleration -> can be calculated simply from the above F = ma equation

v = current velocity

s = current position

it's also important to know about independance of x,y & z velocities. if you apply a force in the x direction, it does not effect the y or z velocities/momentum/acceleration. so you calculate your s(t) independantly for each of the x, y & z axes.

also for computer simulations remember to subsequently calculate the velocity from that same acceleration. after running the s(t) equation to figure out your new postions do:

v(t) = v * t + s
v(t) = velocity at time t.

for the purposes of a game, t = time passed since last frame. you can calculate this using a variety of timing methods (which you can look up elsewhere).

once you implemennt good physics equations applying forces to your spaceship will have the correct results.

if the info in this message isn't enough you should probably spend some time googling around for a good physics tutorial (i'd also suggest looking in the articles & resources section of this site)

-me

[edited by - Palidine on February 6, 2003 4:40:02 PM]

[edited by - Palidine on February 6, 2003 4:40:49 PM]
quote:

If I where to apply those a current time the only thing missing would be "AN OBJECT IN MOTION TENDS TO STAY IN MOTION" so if you turn the engine off nolonger would I move forward.


An object in motion tends to stay in motion with the same velocity and direction unless acted upon by an force.
Your engine is a force. Gravity is also a force. Wind is also a force. In it''s most simplistic application, "space", itself, has no forces like gravity and wind. So, when you turn off your engines, your velocity (and thus, your momentum) will not change unless you apply a force (like reverse thrusters or the gravity from a nearby star or planet).
You also need to apply "terminal velocity" to your space ship (the fastest it is possible for it to go).
quote:
Original post by PropellerBoy
An object in motion tends to stay in motion with the same velocity and direction unless acted upon by an force.
Your engine is a force. Gravity is also a force. Wind is also a force. In it's most simplistic application, "space", itself, has no forces like gravity and wind. So, when you turn off your engines, your velocity (and thus, your momentum) will not change unless you apply a force (like reverse thrusters or the gravity from a nearby star or planet).
You also need to apply "terminal velocity" to your space ship (the fastest it is possible for it to go).



That was what I ment I KNOW that already, Ok I'll go look around for correct formulas and do some more reading.

[edited by - Xero-X2 on February 6, 2003 5:47:40 PM]
"I seek knowledge and to help those who also seek it"
quote:
Original post by Xero-X2
No the problem I have is how to apply to forces. If I were to do it the way I was doing It, it would ADD the forces per second so if you had the engines on at full every second your speed would double! that is bad, unless that really happens which I doubt because according to my knowlege your fastest speed is the speed caused by the most powerful force for instance in a 1d situation.

As long as you don''t go relativistic there is no limit on speed. As long as the force on, the object will continue accelerating.

This topic is closed to new replies.

Advertisement