Calculating angled bounce math

themagicboxthemagicbox 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 ...

Comments

  • themagicboxthemagicbox Member, PRO Posts: 82
    Or maybe a link to a resource on this? Lol
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • themagicboxthemagicbox Member, PRO Posts: 82
    edited May 2013
    i actually saw that page when i was searching on google...haha but i didn;t know how to translate into gamesalad, ill take a lot at it again when i get back but im not confident ill be able to figure it out :S
  • ORBZORBZ Member Posts: 1,304
    Do you know someone who is good at math that you could ask. Often times it's easiest to understand some of these concepts if you can have an interactive dialog with someone. A teacher or prof a local college perhaps?

    Most math teachers are THRILLED to share their knowledge.
  • themagicboxthemagicbox Member, PRO Posts: 82
    Unfourtunetly I do not...it's embarassing cause I'm pretty sure I learnt this in high school..I just forgot most of it lol...I did remember some other stuff with trigonometry that is in my game so I'm glad I could do that but this is the last "intense" math equation I think I'll have to use
  • ORBZORBZ Member Posts: 1,304
    Google "angle of reflection"

    You'll need to compensate for the angle of your collision surface.
  • themagicboxthemagicbox Member, PRO Posts: 82
    edited May 2013
    Yah I figured that I need to take into account the angle surface...and I looked through many angle of reflections explanation but I wasn't sure how to translate it into gamesalad

    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?
  • ORBZORBZ Member Posts: 1,304
    looks reasonable... test it, if it works it's correct :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Why not let GameSalad handle calculating the angles by using the bounce behavior?
Sign In or Register to comment.