Implementing bouncing with HC

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
aidalgol
Prole
Posts: 19
Joined: Tue Feb 07, 2012 7:53 pm
Location: New Zealand
Contact:

Implementing bouncing with HC

Post by aidalgol »

I am trying to implement really basic physics using HC for collision detection, and I seem to have not implemented bouncing correctly. I have a moving ball and a static square, and I am trying to use the separating vector returned by HC.collisions() to change the direction of the ball's velocity so that it bounces off the square when it collides. What is instead happening is that the ball hits the square and travels slower almost completely straight downwards (positive Y axis).

My minimal reproduction of this issue is here: https://gitlab.com/aidalgol/hc-love-collision-bug
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: Implementing bouncing with HC

Post by pgimeno »

The separating vector is not the bounce direction. It's more like the collision normal, but keep in mind it's not a unit vector.

Try with this: http://mathworld.wolfram.com/Reflection.html
aidalgol
Prole
Posts: 19
Joined: Tue Feb 07, 2012 7:53 pm
Location: New Zealand
Contact:

Re: Implementing bouncing with HC

Post by aidalgol »

pgimeno wrote: Mon Nov 12, 2018 6:28 pm The separating vector is not the bounce direction. It's more like the collision normal, but keep in mind it's not a unit vector.

Try with this: http://mathworld.wolfram.com/Reflection.html
Ah, that explains the 90° angle. Thanks! I shall read up on reflection.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 10 guests