realistic jumps
realistic jumps
hi
can somebody told me how to create a realistic jump in fist person view?
i tried something like moving up and down the character but is looks stupid!
and you have to jump forewards if you'r moving forwards!
sorry for my english i'm german
can somebody told me how to create a realistic jump in fist person view?
i tried something like moving up and down the character but is looks stupid!
and you have to jump forewards if you'r moving forwards!
sorry for my english i'm german
-
- Posts: 1
- Joined: Tue Feb 20, 2007 5:20 pm
I'm new to Irrlicht too, but I've got some experience doing some other 3d programming.
What you have to do is have a vector for the character's movement. Irrlicht might already have something that serves this purpose. What it does is keeps track of the velocity of something in three dimentions.
Expressed as (x,y,z), (0, 1, 2) would mean the object is moving up the y axis (upwards), along the z axis (forwards), and staying still on the x axis (sideways).
If you wanted something to move up and down, you'd put the y axis to 1 for a bit while it moves up, then set it to -1 and it would move down.
If you want something to look realistic, you have to think about acceleration. From the point of the jump, Y would start out big. Maybe 1 or something. Then it would gradually get smaller until it reaches 0, at the apex of the jump. Then it would start decreasing, the fall getting faster and faster. A collision detection with the ground would set it back to 0.
What you have to do is have a vector for the character's movement. Irrlicht might already have something that serves this purpose. What it does is keeps track of the velocity of something in three dimentions.
Expressed as (x,y,z), (0, 1, 2) would mean the object is moving up the y axis (upwards), along the z axis (forwards), and staying still on the x axis (sideways).
If you wanted something to move up and down, you'd put the y axis to 1 for a bit while it moves up, then set it to -1 and it would move down.
If you want something to look realistic, you have to think about acceleration. From the point of the jump, Y would start out big. Maybe 1 or something. Then it would gradually get smaller until it reaches 0, at the apex of the jump. Then it would start decreasing, the fall getting faster and faster. A collision detection with the ground would set it back to 0.
All the money in the world would never make me as happy as giving me a simple land crab. I would feed it, nourish it. I guess I'd eventually sell it on the black market for some serious $$$.
somthing like this
in the while loop runing the game
if(character is in the air || jump==true){
jumpspeed+=0.01;
tempos=camera->fetposition();
tempos.Y-=jumpspeed;
camera->setposition(tempos);
}
to activate the jump:
jump=true;
jumpspeed=-10;
in the while loop runing the game
if(character is in the air || jump==true){
jumpspeed+=0.01;
tempos=camera->fetposition();
tempos.Y-=jumpspeed;
camera->setposition(tempos);
}
to activate the jump:
jump=true;
jumpspeed=-10;
Last edited by kompromis on Wed Feb 21, 2007 3:27 pm, edited 1 time in total.
-
- Posts: 13
- Joined: Wed Feb 14, 2007 3:32 pm
- Location: HH | Germany
- Contact:
ok, this idea might be bullshit, but i'm not doing this professional after all:
with all the physics engines around, would it be possible to do character movement based on physics? this would make sure the char is on the ground and if it jumps, you give it an impulse up, which blends with any other movement the char has and it would automatically fall down again?
what do you guys think?
with all the physics engines around, would it be possible to do character movement based on physics? this would make sure the char is on the ground and if it jumps, you give it an impulse up, which blends with any other movement the char has and it would automatically fall down again?
what do you guys think?
Unfortunatly I don't think it's that easy ...
I think there's some problems with physics and user controlled meshes on most physic's engines.
For exemple if your ground isn't "flat", if it's a terrain generated from a heightmap then you can make the character jump and fall down by the physic engine, but then, there will be a collision with your character and the ground ...
And you will have to tweak this collision so the character won't behave like some stupid box or rigid object (if you don't after the jump your character may find himself lying on the ground instead of standing ...).
Anyway this is what happens with ode :p (I know since this is what I'm trying to do :p)
I believe physix by ageia (since it's now free you might take a look) have a userControll class or something like that to make things like jumping and walking with your character simple, but ode don't :'(.
I don't know for bullet and newton ... but I don't think they have this kind of features ...
Edit: There's probably no needs for a real physics engine to fake a realistic jump ... Have you tested a timed function with a sin or cos calcul of the altitude ? So if you're moving the jump would looks like a sinusoid ... that could do the trick.
You could use some code looking like the one from kompromis and change it to react to the time with something like this tempPos.Y += A * sin (omega * t);
This way by tweaking the A and omega parameters it may be possible to make it looks like the falling speeds isn't constant.
I think there's some problems with physics and user controlled meshes on most physic's engines.
For exemple if your ground isn't "flat", if it's a terrain generated from a heightmap then you can make the character jump and fall down by the physic engine, but then, there will be a collision with your character and the ground ...
And you will have to tweak this collision so the character won't behave like some stupid box or rigid object (if you don't after the jump your character may find himself lying on the ground instead of standing ...).
Anyway this is what happens with ode :p (I know since this is what I'm trying to do :p)
I believe physix by ageia (since it's now free you might take a look) have a userControll class or something like that to make things like jumping and walking with your character simple, but ode don't :'(.
I don't know for bullet and newton ... but I don't think they have this kind of features ...
Edit: There's probably no needs for a real physics engine to fake a realistic jump ... Have you tested a timed function with a sin or cos calcul of the altitude ? So if you're moving the jump would looks like a sinusoid ... that could do the trick.
You could use some code looking like the one from kompromis and change it to react to the time with something like this tempPos.Y += A * sin (omega * t);
This way by tweaking the A and omega parameters it may be possible to make it looks like the falling speeds isn't constant.
-
- Posts: 13
- Joined: Wed Feb 14, 2007 3:32 pm
- Location: HH | Germany
- Contact:
good point about the user-input. if it's looking like any box, it's useless.
i don't have any experience with physics. isn't it possible to stop a physics controlled object from bouncing by applying a certain, opposing force? maybe you can use a sphere, constrain its movement to up/down and just update it's position with the character? this would also give you collition detection with walls and such.
i guess i just have trouble to think up the best way to find the correct height value for a user-controlled object on uneven ground (any level structure). if i dont have a height map or real 3d levels, i would need collision detection, right?
i don't have any experience with physics. isn't it possible to stop a physics controlled object from bouncing by applying a certain, opposing force? maybe you can use a sphere, constrain its movement to up/down and just update it's position with the character? this would also give you collition detection with walls and such.
i guess i just have trouble to think up the best way to find the correct height value for a user-controlled object on uneven ground (any level structure). if i dont have a height map or real 3d levels, i would need collision detection, right?
The problem with using a sphere is that sphere tends to roll. When your cube might bounce a little resting on the ground your sphere will roll and your character will most likely follow your sphere movements.
The real problem with physic's engine is that there's a collision detection system and a rigid body simulator. So normally there's a reaction to each collision and it tends to behave like in real world. The problem is that in real world you apply pressure with your legs and this pressure makes you standing up. Simulating this might be really complicated ...
I'm not sure I've understood the last part of your post.
It seems you're more interested in collision detection than rigid bodies dynamics, do you know that irrlicht is able to do collision detection and basic response ? It would keeps you from passing through a wall or ground for example, and I even believe it's possible to get a callback so you can do custom collision reactions.
If you want the "correct height" you could probably use this. When you jump you just change the Y coords of your user-controlled object and stop changing when the object touch the ground (which you should be able to know directly from irrlicht).
Anyway if you didn't knew this take a look at this first, http://irrlicht.sourceforge.net/tut007.html . If it's not enough then you'll have to use a physic engine :p which is a "little" bit more complicated (at least ode is ... ^^ ).
Yes but it's a real pain :p (at least in ode ^^ )isn't it possible to stop a physics controlled object from bouncing by applying a certain, opposing force?
The real problem with physic's engine is that there's a collision detection system and a rigid body simulator. So normally there's a reaction to each collision and it tends to behave like in real world. The problem is that in real world you apply pressure with your legs and this pressure makes you standing up. Simulating this might be really complicated ...
I'm not sure I've understood the last part of your post.
It seems you're more interested in collision detection than rigid bodies dynamics, do you know that irrlicht is able to do collision detection and basic response ? It would keeps you from passing through a wall or ground for example, and I even believe it's possible to get a callback so you can do custom collision reactions.
If you want the "correct height" you could probably use this. When you jump you just change the Y coords of your user-controlled object and stop changing when the object touch the ground (which you should be able to know directly from irrlicht).
Anyway if you didn't knew this take a look at this first, http://irrlicht.sourceforge.net/tut007.html . If it's not enough then you'll have to use a physic engine :p which is a "little" bit more complicated (at least ode is ... ^^ ).
some pieces of code form my program.. works here just put the values
hope i didn't forget anything
i used it on my little fps, not for a bouncing ball or complicated physics just to make the first person camera jump, not a problem to make it bounce
hope i didn't forget anything
i used it on my little fps, not for a bouncing ball or complicated physics just to make the first person camera jump, not a problem to make it bounce
Code: Select all
fCamY += fCamForceY * Time;
if ( bMidAir )
{
fCamForceY -= FallSpeed * Time;
FallSpeed = FallSpeed * power(fGravity);
}
if (fCamY <= LandHeight)
{
bMidAir = 0;
fCamY = LandHeight;
FallSpeed = 0;
}
if (jump key is pressed && fCamY == fLandHeight)
{
fCamForceY = fJumpForce;
bMidAir = 1;
}
if (bMidAir)
{
fCamForceX *= 0.8;
fCamForceZ *= 0.8;
}
then add to to your moving code, where it checkes if key is pressed then says moves, make it check if key is pressed AND if !bMidAir
-
- Posts: 13
- Joined: Wed Feb 14, 2007 3:32 pm
- Location: HH | Germany
- Contact:
thanks for your ideas and help.
kschn, the last part of my post means i always wondered how you would put a character down on the ground (if its not flat anyways) and keep it from falling through it. you answered that pretty much: with basic collision detection, which stops the "falling" movement.
i will give it a try when i find the time for some coding.
kschn, the last part of my post means i always wondered how you would put a character down on the ground (if its not flat anyways) and keep it from falling through it. you answered that pretty much: with basic collision detection, which stops the "falling" movement.
i will give it a try when i find the time for some coding.