Matter-js: Prevent rotation

Created on 23 Jun 2015  路  5Comments  路  Source: liabru/matter-js

Thanks for the great library.

I'm trying to prevent my bodies to rotate. It would be a "unary" constraint. I've looked at the code and issues but it looks like it's not possible currently. If not, I'd be happy to submit a PR if you can put me on the right track!

Most helpful comment

Try set inertia to Infinity when you create your body.

All 5 comments

Try set inertia to Infinity when you create your body.

Awesome! Thanks a lot.

Does that still work? I tried setting my player object's inertia property to Infinity and it still tips over. I tried both:

player.body.inertia = 'Infinity';

And

player.inertia = 'Infinity';

The object still tips over. Note this is with a Phaser JS app using the Matter JS physics engine.

@roschler it needs to be the word Infinity without any quotes as it's a value in JS, then it should work.

@roschler you can use setFixedRotation func
player.setFixedRotation();

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koko236 picture koko236  路  3Comments

probityrules picture probityrules  路  4Comments

liabru picture liabru  路  3Comments

car1ot picture car1ot  路  3Comments

Titozzz picture Titozzz  路  4Comments