PDA

View Full Version : Animation Ball soccer natural gravity

bazbazus
31-01-2010, 02:15 AM
hi to all
I have a question for my football games, so I want to do an animation of the ball with natural gravity , I try with TGLMovementPath and TGLPathNode, but the animation is not natural.

Here is a video that I created with After affect, he show the animation that I want to do.
exemple :
thank you to all

User137
31-01-2010, 08:24 AM
Think of the ball as a big sphere particle. You have position and movement vectors (3D-vector is x,y,z coordinates). Each game tick ball's position vector is increased by its movement vector, and movement vector's Y-coordinate is decreased by gravity. When ball hits ground level, position vector is moved on top of ground, movement vector is scaled down by.. say multiplying Y with 0.3 (so next jump is smaller than last, in football much smaller) and Y is turned negative (this is the bounce effect).

But when we take grass into account we know that certain point ball won't bounce up anymore but instead starts rolling. You can by testing see by maybe "if movement vector's Y is < 0.2 then movement vector's Y = 0.

if KickKeyPressed then begin
moveY:=KickStrength*0.9;
// feel free to change constant fitting, this effects angle that
// ball flies upwards

end;

moveY:=moveY-gravity;

posX:=posX+moveX;
posY:=posY+moveY;
posZ:=posZ+moveZ;

// hits ground
if moveY<-0.1 then // if speed 0.1 is lowest bounce after rolling starts
moveY:=-moveY*0.3 // bounce up
else
moveY:=0; // start rolling
moveX:=moveX*0.993; // Again feel free to experiment with slow-down constants
moveZ:=moveZ*0.993;
end;

bazbazus
31-01-2010, 06:03 PM
hi User137 thank you ,
you can give me this exemple ,with project delphi

User137
31-01-2010, 10:21 PM
I don't have GLScene at all so i won't be able to test this thing for you ;)

chronozphere
01-02-2010, 02:57 PM
Try it yourself and learn!

No offense, but If you keep asking others to do the work for you, you may need to consider taking a step back and make pong first (like most of us did). :yes:

bazbazus
01-02-2010, 06:16 PM
i have not interstand the code source then i can try it my self :(

Brainer
01-02-2010, 09:19 PM
No offence as well here, but maybe game development is a little too hard for you yet? Try developing some simple apps and moving further, instead of hopping into the deep water.