Jump to content

How to improve hit detection / collision


Recommended Posts

I'm creating a game that is basically a clone of the example Breakout  (http://phaser.io/examples/v2/games/breakout) You can use that as a reference for my code.


My issue is that the hit detection is terrible when moving the paddle left to right and hitting the middle of the ball. In the Phaser example you can clearly get the ball to overlap the paddle with no hit detected.


I've added an Overlap check to my paddle and the ball that is correctly firing, but it doesn't look good  visually when the ball is actually overlapping the paddle. I


I've tried throttling how often you can update the position of the paddle, but this makes the movement of the paddle jittery.

var throttled = _.throttle(doMovement, 17);

My question is if there is a better way to implement the hit detection?


I'm new to HTML5 game development, so if there are libraries or best-practices that are supposed to be used for this, please let me know :)



Link to comment
Share on other sites

I've used several machines, all running at 60FPS.


How fast are you moving the paddle and are you hitting the ball on the left or right side of the paddle? I see the error mostly ocurres when I have a high acceleration/speed when moving.

If you still have good hit detection at faster speeds then I will record a video of it when I get home.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...