The bouncing ball

For questions about using Classic.

Post » Thu Nov 04, 2010 12:11 am

Hello dear Constructors!! :D

In my latest project I've recently run into an annoying problem. I'm creating a game revolving around a bouncing ball that is supposed to bounce across flat and angled surfaces. While the 'Bounce' action works fairly well to simulate the bounces, the direction the ball gets from the bounce seem to include some kind of random element. This since the ball bounces in differnt ways everytime I test it out even though the layout of the map remaines the same. In my project it is important that the ball bounces in the same way every time.

My first question is therefore, is there a way to "fix this", to force the ball to bounce the same way every time, or do I need to create this kind of physics myself?

If the only solution is to do it myself, how is the most effective (noncomplex) way to create this? before I've just inverted the yVelocity everytime the ball hits the ground, but on angled surfaces I need another formula (using vectors, angles?).

Any help is Greatly appreciated!! :D

Posts: 8
Reputation: 716

Post » Thu Nov 04, 2010 12:52 am

law of reflection states that:

the incident angle from the normal equals the reflected angle from the normal.

for perfectly elastic reflections (bounces) your going to need to find the normal of the surface at the point the ball hits. then your going to need to find the angle the ball hit that surface from relative to the normal, and your going to want to change the angle so that its that amount from the normal opposite from where it hit.

you should look into using the custom movement behavior, im not entirely sure but i think theres an easy way to do all this using it.
Posts: 1,940
Reputation: 7,248

Post » Thu Nov 04, 2010 9:33 pm

This might interest you:


I noticed the same problem myself, and the only solution was to use the custom movement behaviour. The events are as straight forward, but you have more overall control.
Posts: 105
Reputation: 1,510

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests