I need to know how I can check in Farseer Physics if a player/user clicks on a specific body, is this possible?
Do I have to write my own methods?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
Mouse.GetState()and compare the mouse state this frame with the state from the previous frame (you have to store it) to determine when and where clicks occur. This should be trivial, so I won’t go into further detail (if you need it, ask an additional question specifically about XNA and not Farseer).Once you have your mouse position as a
Vector2, pass it toWorld.TestFixture(Vector2 point)which will return aFixture. (You can also useTestPointAllto get a list of fixtures, if you want to handle having more than one under the cursor).If you want a
Body, use theFixture.Bodyproperty.