Making the bounce angle different depending on where it hit an actor

How do I do this? I am making a breakout style game. And all is going well, although when the ball hits the edge of the paddle I want it to bounce in a different direction then to if it bounced off the middle of it and so on. \

Thanks in advance.

Answers

  • sparx13sparx13 Member Posts: 97
    bump.
  • epicstagepicstag PRO Posts: 132
    It's late and I don't have time to plot out all of the math for you, but what I would do is think about your know variables:

    entryAngle. Say its 30 degrees.

    I'd set the center of the paddle to return the ball at the negative entry angle. (note this is not -30, its actually 180-entryAngle)

    Since you probably want the ball returning at least in the opposite direction, I'd set one far end of the paddle to return to 90 degrees, and the other far end to return at 180 degrees.

    Then I would use proportions to calculate the actual return angles I wanted to use based upon where on the paddle the ball hit, and which way it's moving.

    I hope that helps a little.
  • sparx13sparx13 Member Posts: 97
    Sorry I am still learning and I am unsure of how to do that. Can someone give me a more detailed explanation of how to do it?

    Thanks.
  • ElfizmElfizm Member Posts: 489
    Have you had a look at the GS demo one, don't know if they still provide it with all the other free demos.

    Elfizm
  • sparx13sparx13 Member Posts: 97
    I couldn't find this demo, can someone give me a link or something for it or just help me out by saying what has to be done.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    On the ball actor you should have a rule that looks like this:

    When overlap or collides with actor of type Paddle
    -- Change attribute self.Motion.Linear Velocity.X to self.Motion.Linear Velocity.X+2*(self.Position.X-game.Mouse.Position.X)

    This is based on the assumption that you move the paddle with the touch or the mouse.

  • ElfizmElfizm Member Posts: 489
    Sent you a PM :)
  • sparx13sparx13 Member Posts: 97
    MarkOnThelron I did as you said and yes I do move the paddle with the touch of the mouse but the ball either goes on a weird down angle or straight through the paddle.
  • sparx13sparx13 Member Posts: 97
    ooops I got it working using what you said all I had to do was add another bounce when colliding with rule.

    Thanks heaps.
Sign In or Register to comment.