New to Farseer - Just a few simple Questions

Topics: Developer Forum, User Forum
Apr 28, 2011 at 3:26 PM

Hey guys,

I'd like to use farseer in my xna game, but I'm fairly new to XNA and am having some trouble getting farseer working the way I need it to. Could you guys help me out?

 

1) I'm creating a top down game, so I understand I need to disable gravity. How can I do this globally? (I know how to use the IgnoreGravity bool on Bodies)

2) With gravity disabled, what is the command to enable friction on bodies so that they will slow down over time, would I use Body.LinearDamping field?

3) I'm using the XNA Hello World farseer sample, and I'm trying to get the camera to follow the circlebody. For the life of me, I can't get it to work.

_cameraPosition = circleBody.Position; SHOULD work, but it doesn't, at all, even thought if I output the positions of both the circleBody and the _cameraPosition to a string they match.

The view never changes. I have a feeling it has to do with the view matrix, but I'm not knowledgeable enough to understand how to fix this. 

 

If I can get over these few, simple hurdles, I will be able to get going on my game. It's a simple game, that doesen't require a lot of physics, but using farseer will be far eaier then trying to code my own psuedo physics. 

Any help you can provide would be very, very appreciated!

 

Thanks,

John

Developer
Apr 29, 2011 at 5:48 PM

1) Set World.Gravity = Vector2.Zero

2) Yes, Body.LinearDamping

3) You probably need to use Camera.TargetPosition. If that doesn't work, try stepping through the camera update method.

 

Good luck

Apr 29, 2011 at 6:33 PM
Edited Apr 29, 2011 at 9:14 PM

Ok, the Hello World doesn't appear to include the Camera class, jsut a psuedo-camera. Maybe that's why I'm having so many issues!

I'll try using the full farseer xna code...but I'm so new to XNA that the full samples are very confusing in that there are so many files. 

I know this may be asking a lot, but would really, really help me out. Is there any way you could implement the Camera2d class into the hello world sample, so that I could see how it is supposed to work?

I'm just not sure how to do this myself without a little help =(

Thank you!

Developer
Apr 30, 2011 at 2:03 PM

Unfortunately I don't have time to help with that. I think the best thing you can do is dive in, review the test bed samples and look for one that has camera tracking going on -- I seem to remember the car one does but I could be wrong.

May 6, 2011 at 5:33 AM

If you edit GameDemo1.cs in the Samples directory (in the "Samples XNA" project) and change this line:

EnableCameraControl = true;

To this:

EnableCameraControl = false;

The camera will follow the car. This just tells it to not let the player control the camera.