This project has moved and is read-only. For the latest updates, please go here.

[SOLVED] Inverting gravity and static objects

Dec 10, 2011 at 3:48 PM

Hey guys,

I'm creating a platformer where I need to do two kinds of manipulations to different size rectangles. The first kind is that when I shoot a projectile at a certain rectangle, that rectangles gravity is inverted. The second kind is taking control over the whole body, so it will follow the mouse cursor around, which should work just fine using the current method(s).

At the moment I'm achieving this by having a dynamic body and applying a linear impulse continuously upwards if the rectangle should inverse its "gravity". This introduces a bit of a problem though, as if my player body or other rectangle bodies come in contact with the rectangles while they're moving, they start rotating and flying around here and there. This is of course expected with a dynamic object, so it's not like I'm complaining here. ;-)

Anyway, what I'm asking here: Is there a way to achieve this kind of functionality, but while allowing collisions with other rectangles/player, it wouldn't affect the physics of the object, eg. it wouldn't start spinning/rotating, but instead just keep "pushing" or applying a pulse until reversed.


I guess I'm looking for some kind of "rotation locking", but then again, if any of you think of another way of doing this, please let me know. :-)

Dec 11, 2011 at 3:52 PM

Yourbody.FixedRotation = true;

Dec 11, 2011 at 4:03 PM

Thank you!

That's exactly the kind of functionality I was looking for. :-)