Calculating angled bounce math
themagicbox
Member, PRO Posts: 82
Hello!
I have a ball that bounces off walls that are horizontal and vertical...I have a rule on the ball to reverse its x or y linear velocity when it hits a wall...I found out this simple rule only works for horizontal and vertical walls and I have some angled walls in the game....how would I calculate the bounce it would have? I'm not a great math person so I'm not sure of the equation ...
I have a ball that bounces off walls that are horizontal and vertical...I have a rule on the ball to reverse its x or y linear velocity when it hits a wall...I found out this simple rule only works for horizontal and vertical walls and I have some angled walls in the game....how would I calculate the bounce it would have? I'm not a great math person so I'm not sure of the equation ...
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Most math teachers are THRILLED to share their knowledge.
You'll need to compensate for the angle of your collision surface.
I think I figured it out though...this equation seems to work on changing the direction to the right angle when collided with an angled surface...
2*(angle of collided surface)-(vectortoangle(linear x and y velocity of ball))
it had an minus 180 at the end but I don't appear to need that as it works like the way it is up there...I've testing it with 2 angles in my game, 270 and 135 and it works good....
can anyone verify this math?