Jump to content

Manual physics body JSON generation


GameDemon
 Share

Recommended Posts

Hi, I want to create a physics body for a simple shape - basically a hollow rounded rectangle. My PhysicsEditor trial has expired (installed it then didnt use it for a month, woops) and I can't see a good alternative to use :-(.

 

However, as the shape is simple I thought that if I use a vector graphics app like Adobe Illustrator I could copy down the coordinates of the points and make my own JSON file.

 

Are there any considerations for doing this? I assume the polygons have to be convex,  So I should make shapes with 3 or 4 vertices.

 

Could anyone give me a quick rundown of the JSON, ie what ranges the density/friction/bounce values should be in, and if I need to set the filter.

{"density": 2, "friction": 0, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 },"shape": [   128, 880  ,  112, 896  ,  112, 176  ,  128, 176  ]}
Link to comment
Share on other sites

Thanks a lot for the link chong, I will make a separate post on parameters because I have loads of questions about that... confused.

 

One heads-up for people creating the polygon vertices manually, they need to be defined in clockwise order (even though the error says 'anti-clockwise')

Link to comment
Share on other sites

@GameDemon - Contact me at support at codeandweb.com - I can extend your trial license.

 

Most of the parameters are currently not used - this is because the reader only loads the vertex data. It's easy to extend the importer to make use of the parameters - but I had not time to work on it yet.

 

About creating the data manually:

 

* make sure you use the right winding order 

* make sure your shapes are convex - if you have concave objects split them into convex ones

 

Btw. we've creates a short tutorial that should help you with the setup of a simple physics game here:

 

https://www.codeandweb.com/blog/2015/10/07/phaser-p2-physics-example-tutorial

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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