Jump to content

Physics body made of multiple simple polygons or just one complex polygen, P2 performance


megabyterain
 Share

Recommended Posts

I'm making a game with a lot of asteroids. I noticed that my fps drops the more asteroids I add when running on the 2015 i7 Macbook Pro. That probably means that on less powerful laptops will lag a lot? My asteroids are similar to the ones in the game Asteroids, however I wanted them to have a somewhat realistic collision body shape that represented the sprite shape. On the Phaser p2 examples I noticed that the json for physics bodies' shapes were broken into smaller shapes
 like this

{
[1,2 , 3,4 , 5,6], //pretend that this is a triangle
[7,8 , 9,10 , 11,12], //pretend this makes another triangle
[13,14 , 15,16 , 17,18] //pretend this makes another triangle
}
//pretend if you put all of the those shapes together it would make another shape

as opposed to just having it as one complex shape like

{
[1,2 , 3,4 , 5,6 , 7,8 , 9,10 , 11,12 , 13,14 , 15,16 , 17,18] //pretend this makes a shape
}

Which is better for performance?

Also I want to have maybe around 200 asteroids in my game at a time, not to mention some other bodies as well. Should I reduce the amount of vertices of the asteroid's collision bodies? Would setting it to be a circle be less power demanding? The game works fine on my desktop, but that has a gtx 970 and I doubt most people who play my game will have that sort of power.

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.

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

  • Recently Browsing   0 members

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