Search code examples
farseer

Fixed Revolute Joint in farseer 3.5


Hi I'm currently new in farseer physics engine, anyway, I have read tutorial about farseer 3.31 here http://roy-t.nl/index.php/2012/09/06/farseer-physics-3-3-1-and-xna-joints/

in the tutorial he's trying to attach/join paddle body to world withJointFactory.CreateFixedRevoluteJoint , unfortunately in farseer 3.5 there is no CreateFixedRevoluteJoint method, it's only CreateRevoluteJoint which is joint two bodies, so how can I revolute joint one body to world object ?


Solution

  • Use a RevoluteJoint. And make your paddle rotate around another object. Like so:

    Body motorPaddle = CreateMotorPaddle();  
    Body motorPaddleAxle = BodyFactory.CreateCircle(World, 0.1f, 1f);  
    
    var j = JointFactory.CreateRevoluteJoint  
        (  
            World,  
            motorPaddle,  
            motorPaddleAxle,  
            new Vector2(0.0f, 0.0f),  
            new Vector2(-14.0f, 10.0f)  
            );  
    
    // set speed and torque  
    j.MotorSpeed = MathHelper.Pi;  
    j.MotorImpulse = 100;   
    j.MotorEnabled = true;  
    j.MaxMotorTorque = 100;  
    

    More details here