Ideal collisions with borders SOLVED

Petrik33

Member
Hello everyone, actually I am a newbie in programming physics, so I need help with setting up proper and ideal collisions between my circles and borders, So to understand it clearer without screenshot(will add it soon) imagine a Box with coin in it(2D) and I need to set up collisions of this coin with box borders. Help me please.
 
Z

zendraw

Guest
you simply check for place_meeting on the left/right up/down and repell coin if it collides, also you can clamp the coin to stay in the box
 

Alexx

Member
With regards to the spin and using that to alter the angle slightly.
One approach:
Use a variable, perhaps clamped between -5 and 5.
When calculating a bounce of a side, apply this value to the bounce angle.

Like @zendraw said, check for each side.
Probably need tweeking to detemine from which direction the ball has can from.

Doable in only a few lines of code.
 

Petrik33

Member
With regards to the spin and using that to alter the angle slightly.
One approach:
Use a variable, perhaps clamped between -5 and 5.
When calculating a bounce of a side, apply this value to the bounce angle.

Like @zendraw said, check for each side.
Probably need tweeking to detemine from which direction the ball has can from.

Doable in only a few lines of code.
Thank you very much. Actually my code seems to be pretty right then but some ocassions still ocur in situaltions like on screenshots below
 

Attachments

Top