I am attempting to create a 2d shooter in Farseer Physics on the Xbox360.

I have a player body which has a fixed rotation, as I do not want the body to rotate at all during gameplay. I am now looking to add an arm/weapon to the player's body, which should be able to rotate when the player moves the thumbstick on the controller.

This arm should have the following features:

  • Does not react to gravity
  • The position does not change by itself
  • The only time the angle should change is when the player tells it to do so, and I should be able keep it at a fixed angle when the player decides to stop moving it.

Originally, I thought I could get this done using a fixture. Unfortunately, I don't see a way to rotate a fixture on a body after it has been added.

I assume the correct approach is to create a seperate body for the arm of the player, and attach them using a joint. I cannot for the life of me figure out which joint to use, and which characteristics to apply it. I feel like I have tried all of them, but I'm sure there are just a few variables that I am unfamiliar with that are giving me unwanted results.

  • \$\begingroup\$ @Serris, I am more so struggling with actually attaching the arm to the body in a way that will allow me to rotate the arm without rotating the player's body. \$\endgroup\$ – Feek Sep 30 '14 at 15:47
  • \$\begingroup\$ Why do the arm and body need to be physical objects? Why not simply draw them at their appropriate places without interacting with physics at all? \$\endgroup\$ – mklingen Dec 30 '14 at 14:54

conceptually, you would split off the main body sprite, and the rotating arm sprite. then you use the same transformations on the arm as you do on the main body. when you want the arm to rotate you set the arm sprite's origin point to the shoulder of the body sprite and rotate around that.

once your characters arm reaches an unrealistic angle, simply flip the character and have it run backwards.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.