Breaking the laws of physics... Problem

Hi all, I’m trying to remake this in Corona: http://www.nebulabytes.com/impossible_bounce/

Aside from the obvious problems compared to making this in Flash, like the absense of bezier-built physics bodies and the fact that it’s become kinda difficult in Corona, to rotate display groups around an anchor-point (without Containers…Messy!) I’m actually doing OK… I’ve used joints to control the rotation and 36 ‘bricks’ for my circle.

My problem is how they’ve managed to apply an un-natural bounce to the ball, in a pre-specified direction.

The ball seems to react to an invisible reference point, and bounces towards it after each collision cycle.

Does anyone know how I can apply a linear impulse, or more accurately, set linear velocity in the direction of a 3rd party reference, like an off screen, or invisible) target?

Thanks

Hi @Caithan Games,

It’s fairly easy to apply an impulse or velocity toward a direction. You should just compare the difference (both x and y) between the ball and the target point (wherever it is, even off screen). Then, you’ll need to factor the values by a certain ratio, to ensure that neither velocity vector is unacceptably high or low. And, inverse those values so the force/velocity is going in the correct direction, and apply it to the body.

As a very simple example, let’s say the ball is at 50,40 and the touch point is at -100,10. Subtract -100 from 50 (= 150) and 10 from 40 (= 30). Now inverse these to get velocity values of -150,-30. Now, you could just apply these values to the ball, but more likely, you’ll want to factor them by a certain ratio that makes sense for the game (these might be too fast, or too slow). So just multiply both by a percentage, and go from there.

Hope this helps,

Brent

P.S. - Note that you can create “bezier shape” bodies using edge/chain shapes. It’s outlined in the guide:

http://docs.coronalabs.com/guide/physics/physicsBodies/index.html#create

Hi @Caithan Games,

It’s fairly easy to apply an impulse or velocity toward a direction. You should just compare the difference (both x and y) between the ball and the target point (wherever it is, even off screen). Then, you’ll need to factor the values by a certain ratio, to ensure that neither velocity vector is unacceptably high or low. And, inverse those values so the force/velocity is going in the correct direction, and apply it to the body.

As a very simple example, let’s say the ball is at 50,40 and the touch point is at -100,10. Subtract -100 from 50 (= 150) and 10 from 40 (= 30). Now inverse these to get velocity values of -150,-30. Now, you could just apply these values to the ball, but more likely, you’ll want to factor them by a certain ratio that makes sense for the game (these might be too fast, or too slow). So just multiply both by a percentage, and go from there.

Hope this helps,

Brent

P.S. - Note that you can create “bezier shape” bodies using edge/chain shapes. It’s outlined in the guide:

http://docs.coronalabs.com/guide/physics/physicsBodies/index.html#create