Attaching a weigh on a rigidbody

Attaching a weigh on a rigidbody


Hey I have this rigidBody(Black triangle) that flies and it spins, but I want one edge of it to always look at the bottom so I thought if I could like put a weigh(red triangle) on that side it would do that, but I don’t know how I can do that help, please

I asked the same question before but nobody answered so I repost with a different style


@slackmoehrle help please


why not just set fixedRotation = true (or allowRotation = false)


because i need it to spin

bende türküm bu arada :slight_smile:


süper! Basarilar! :slight_smile:

I never used physics with cocos creator… but in cocos2dx and box2d I would do this by adding multiple fixtures to the body… the red triangle (fixture) with more weight than the other ones. :+1:


Türkiye güzel bir ülke!

Ok not sure on Cocos Creator. Can you tell me what this: want one edge of it to always look at the bottom means? I don’t follow.
@Big_Bear might know.


Did you means that you want a corner always at the bottom no matter how you rotate the triangle physical.
if that is your means,you can change the mass center of the triangle to realize it.
change the center of mass like this, and use a downward gravity.

you can customize engine,used the box2d api “SetMassData” to set the

            var massData = this._b2Body.GetMassData();
   = b2Vec2(x,y);

ps:attention to the unit,use the “PTM_RATIO”(pixel to meter)


Well this would work but i need it to fly so i’m gonna try moving the center on the opposite side. if this doesn’t work like i want it to i’ll try using fixtures and if that doesn’t work i’ll let you guys know :slight_smile: Thanks


but if i change the engine isn’t everything else’s center gonna change too?


the solution just need you to package the setMassData func of box2d,then you can use the packaged api where you need it.


hey i don’t know how i’m going to package it any links for help maybe ?


hey? @Big_Bear


hey @Big_Bear i’m still waiting for your reply :blush: thanks

@slackmoehrle hey ok i think can you tell me more about fixtures because i can’t find anything about them that i understand any JS documents for that? (edited since i can’t reply more than 3 consecutively)


Let me find out what references we have


Found anything?

edit: sorry for being a pain in the ass but this is kind of what’s holding me on development of the game and i kind of have this goal to publish it before new year because i’ve been procastinating for too long :grimacing:

edit1: @slackmoehrle


I thought one of the demos we had used spine. I’ll try to find it.


Thanks so much :blush:


The engineering team said to take a look at this demo:


what should i be looking at i don’t know i don’t see anything related to physics am i supposed to do this spine thing ?



Hey can you tell me how am i gonna package setMassData func of box2d please???