Jump to content

P2 bodies trigger contact onBeginContact before bodies actually touch


Recommended Posts

I'm creating 2 circles using graphics and adding them to sprites. I'm trying to make the sprites contact each other, but the function added on onBeginContact is called before the objects touch. I have a jsfiddle here: http://jsfiddle.net/vL6gkeue/

 

Can anyone please let me know why there is space between the two bodies yet they appear to have made contact? 

Link to post
Share on other sites
var blobSize = 20;var circObj = new Phaser.Circle(0, 0, blobSize);blob.body.setCircle(blobSize);

It may be that Phaser.Circle takes a diameter, but body.setCircle takes a radius.

 

 

I've tried reducing the size used when calling setCircle significantly, but the collisions still occur before the bodies touch. Debug is enabled on both bodies in the jsfiddle and you can see their sizes are the same as the circles that have been drawn. I'm sure I'm missing something, but I just don't know what it would be.

Link to post
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.

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

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...