Keeping a sprite rotated correctly (disabling rotation)

Dec 30, 2010 at 9:22 AM


I'm new to the library but am developing a platform based game similar to commander keen and would like the physics engine to control the players movement, but would like for the player to not rotate during movement. (i.e. the player will remain upright at all times)

Can someone please point me in the right direction to achieve this?



Jan 1, 2011 at 2:36 PM

Hi Mccabela,

programatically you can achieve this like this (in the Helper 4.0 beta Version using Farseer Engine 3.0, in previous engine verions it is a little different):

PhysicsStprite obj = _physicsController.PhysicsObjects["playerObj"];
obj.BodyObject.Inertia = float.MaxValue;

You can do this in Blend as well, in the PhysicsObjectBehaviour Properties. It is called "MomentOfInertia" there. The higher the value, the less the object will rotate. Infinite will prevent rotation completely...


Mark Kane

Jan 2, 2011 at 12:33 AM

Thanks heaps! Worked a charm.