Jump to content

Center of mass for custom body shapes?


onefatman
 Share

Recommended Posts

Hey all,

 

I've got a cartoony dinosaur character sprite with a custom poly body that i've created in PhysicsEditor that has a large head at the top-left and a small body/legs at the bottom-right. It's P2 physics-enabled with a fixed rotation so it doesn't fall over, it has gravity in place and a large static floor sprite that it collides with to act as the ground. I've found that due to the top-forward-heavy shape of the body it does a very slow creep to the left of the screen that is almost impossible to notice as it happens but if you leave it for 5 mins and come back he's slowly crawled halfway across the screen. I originally hacked around this by just adding an invisible platform to the bottom of the body at the front in order to balance out the centre of mass, but now for other reasons that's no longer going to be possible. I took a look at the body.adjustCentreOfMass() function but it doesn't allow any parameters and the documentation is pretty vague on what it actually does, and when I call it it just causes the character to float about 10 pixels above the ground. Does anyone know of a way that you can play with the centre of mass of a sprite that has a weird-shaped body in order to stop this from happening? And has anyone had anything like this before? I had a look around but can't find anything on the topic at all.

 

Cheers,
ofm 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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