How do I simulate a realistic bouncing ball

0 favourites
  • 8 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • How do I simulate a realistic bouncing ball without physics... over time it should slow down , bounce less..etc... like a real ball....is it possible ? thanks guys

  • Without the physics behavior you could use the bullet behavior with gravity. Then when it collides with the ground use the bounce action and set the speed lower.

    You could go further by learning the math behind it. Some basic physics course should get you there. There are lots online. Or if you want a specific example there are a few you can find with a forum search.

  • hi R0J0hound, you seems the king of C2...if you could provide me with a code for realistic bounce +gravity like a ball...it would be amazing.... Math ?... I am totally discalculic and dislexic... would be almost impossible 4 me...

    thanks 4 ur time

  • Sure, here's all that's involved. The velocity increases or accelerates downwards, and the ball it moved by the velocity vertically. Then when the ball hits the ground the velocity is reversed and multiplied by 0.5 to half the next bounce height. You can adjust the gravity by changing the 1 to anything else.

    var velocity=0

    every tick:

    --- add 1 to velocity

    --- ball: set y to y+velocity

    ball: on collision with ground

    --- set velocity to -0.5*velocity

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thanks a lot... what must I do if it's a ball that I shoot from a cannon that has bullet behavior ?

  • at the end the ball should stay on ground ...

  • If the ground is just flat then the above still holds true. Just change velocity to velocityY and add a velocityX.

    When you launch from the cannon you have a speed and angle in mind so you set the velocities with trig:

    Set velocityX to speed*cos(ang)

    Set velocityY to speed*sin(ang)

    And add an event to move horizontally:

    Every tick

    ---ball: set X to x+velocityX

    This can get as elaborate as you add more features. I won't be able to explain it all. The physics behavior is there for a reason. It's probably better to use that for what you know.

  • thanks 4 ur kindness

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)