Results 1 to 7 of 7

Thread: Animation Ball soccer natural gravity

  1. #1

    Animation Ball soccer natural gravity


    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 :
    http://www.youtube.com/watch?v=k4lunhOeFaw
    thank you to all
    Please answer me

  2. #2

    Re: Animation Ball soccer natural gravity

    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.

    Code:
    if KickKeyPressed then begin
     moveY:=KickStrength*0.9; 
     // feel free to change constant fitting, this effects angle that
     // ball flies upwards
    
     moveX:=KickStrength*cos(RadAngle);
     moveZ:=KickStrength*sin(RadAngle);
    end;
    
    moveY:=moveY-gravity;
    
    posX:=posX+moveX;
    posY:=posY+moveY;
    posZ:=posZ+moveZ;
    
    if posY-BallRadius<groundlevel then begin
     // hits ground
     posY:=groundlevel+BallRadius;
     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;

  3. #3

    Re: Animation Ball soccer natural gravity

    hi User137 thank you ,
    you can give me this exemple ,with project delphi
    please

  4. #4

    Re: Animation Ball soccer natural gravity

    I don't have GLScene at all so i won't be able to test this thing for you

  5. #5

    Re: Animation Ball soccer natural gravity

    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).
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6

    Re: Animation Ball soccer natural gravity

    i have not interstand the code source then i can try it my self

  7. #7

    Re: Animation Ball soccer natural gravity

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •