Jump to content

Detect circle collision inside shape


Recommended Posts

13 minutes ago, jjwallace said:

is this for a user interface?  I only use my own physics so :( 

I am not sure if P2 has that function, perhaps there is a way.

This is for a game.

And yeah. Whenever I load it the circle goes out the shape.

Link to comment
Share on other sites

On 1/8/2017 at 6:17 PM, samid737 said:

If you know your polygon shape data and you are working with simple shapes (like the example provided), you could try  something like this :

 Another idea: If you have your geometry data , you could try addLine and create connecting lines...  Still not very convenient however...

It works, but the thing is that I'll be using complex shapes, I used this one so you could get my idea. 

Link to comment
Share on other sites

 Here is an example of how to generate the shape by hand so to say:

The idea is to build the shape from your data points (they must be ordered as a path) so that it will act as a closed surface (its is not entirely connected, but its super close). You could use this if your shape is not too complex ( disconnected, then it will definitely fail). In the example the shape is interpolated, but you dont have to do this...

I think you can also build your polygons using other software, but I have not used them yet....If you make random shapes in your game, then the example would be pretty useful. Also, you can see that you have to consider performance carefully (many p2 bodies).

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