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
Implementing bouncing with HC
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Implementing bouncing with HC
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
Try with this: http://mathworld.wolfram.com/Reflection.html
Re: Implementing bouncing with HC
Ah, that explains the 90° angle. Thanks! I shall read up on reflection.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
Who is online
Users browsing this forum: No registered users and 12 guests