Basic Jumping Physics

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
GundamO
Posts: 9
Joined: Thu Nov 11, 2010 11:34 am

Basic Jumping Physics

Post by GundamO »

Hey guys,

I have my model able to jump in my game but it is basically increase Y position until timer reaches time then decrease Y until there is a collision.

Code: Select all

if(turtle->jumping){
				TurtlePos.Y++;
				jumpTimer++;
				if(jumpTimer > 70)
					TurtlePos.Y-=3;
				if(jumpTimer>140)
					turtle->jumping = false;
			}
Basically i want to add some physics to it to make it more realistic, only problem is im not too sure how to go about it or how to write the formulae.

Would be grateful for any help
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Use an actual physics engine like bullet, there are different wrappers for it available in the project announcements forum

Implementing your own physics routines can work, but only if you have a lot of time on your hands and if you have a lot of expertise on the subject and on optimizing algorithms to run at an acceptable speed in real-time (which is not an easy task, trust me)
kalvinorama
Posts: 10
Joined: Sat Jul 19, 2008 12:27 pm

Post by kalvinorama »

or you can just use newton's law

mass*acceleration = Sum of force applied to object
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

kalvinorama wrote:or you can just use newton's law

mass*acceleration = Sum of force applied to object
Newton's second law of motion would have to be followed, but although it might sound simple you can't just slap the formula in there somewhere and call it a day

You'll need to keep track of forces, mass and acceleration of the bodies you want to use and you'll need to analytically solve the equasion presented by these factors

Also, newton's second law is only perfectly applicable to point-masses, which do not have a specific center of gravity (the point itself is the center of gravity) or a volume (so torque can be neglected)

And finally, newton's second law alone will not take care of collision
I know irrlicht can handle collisions, but a physics engine can do this so much better with a much higher precision and a smaller chance of glitches like phasing, etc.

Bottom line: Try a physics engine, get familiar with how to use it, since in the end you'll probably always need one if you're going to write a game including physics
Post Reply