Sign in to follow this  
onefatman

Center of mass for custom body shapes?

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 

Share this post


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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.