3 quick questions for a sidescroller/platformer

Apr 6, 2009 at 12:19 AM
Hey guys I have implemented farseer into my current sidescroller/platformer game but I really just can't tweak the physics to get the movement feel I want for the game (ie. make the character not bounce, not feel sluggish when starting to accel, etc.). I have searched the discussions and found some fixes for these problems but it seems like a lot of messing around when I want the movement to feel kind of oldschool / fake anyways (and my game doesn't REALLY need physics). However, I absolutely love the way farseer can create geometries from images. I have my whole level loaded in through images via xml and it makes collisions and such so awesomely easy now. So my questions are:

1) How do I turn off the physics but keep the collision detection.
2) I have seen a few threads mention having the player be a circle connected to a rectangle body with an angle joint or something to create proper looking physics. If I turn physics off will I still need to implement something like this (ie. if my player is just a rectangle or just a circle will the collisions still properly work with hills and bumps in the level).
3) If I do still need to implement the circle+rectangle player body, how exactly is it done?

Thanks for this awesome engine, it has inspired me to fully integrate physics into my next project.
Apr 6, 2009 at 12:59 AM
First of all, thanks for the kind words.

Now, to answer your questions.

1. You are able to turn off most of the physics. You can disable gravity (setting gravity to zero or use IgnoreGravity on the bodies) and remove the calculation of impulse upon impact (by setting the CollisionResponseEnabled property to false).
Just turning off those two will make sure that physics is not calculated. Forces and impulses can still be used on the body tho. The collision detection is still active and the OnCollision event will still work.

2. Have you a link to the post you are referring to? Having a circle (as head) and a rectangle (as body) would create realistic physics (in the sense that it would simulate a torso and head) compared to just having one big rectangle. Mass is distributed more uneven and you have the possibility of reacting differently when your character is hit in the head or the torso. (Think point games and shooters)

3. Well, it's up to you really. If you want a player torso and body, go ahead. To implement it you create 2 geometries with the GeomFactory object. One circle and one rectangle.
Place the two geometries over each other with a small gap between them and create an AngleLimitJoint between them using the JointFactory object.
Set the angle limit to a desired max and min. (This would make the head rock a little, if you don't want that, just set max and min to the same value)
That should be it. Very easy.
Apr 6, 2009 at 2:37 AM
Ok that sounds great, thanks for the detailed response! 

I was actually meaning a circle for the feet and rectangle for the rest of the the player. Basically people were saying that by doing this it would allow the character to walk up hills and such more smoothly than with just a rectangle. heres the link to the post i was looking at:
http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=51544  read the last reply by Robert Dodd. Basically all i need to know now is if the collision of a rectangle going up a slope with the physics turned off will be any different than if the physics were on. (ie. is it the physics causing the rectangle to act strangely or the collision or a combination?). Anyways if the circle+joint+rectangle solution is as easy to implement as it seems then I might as well just do it eh?

Thanks again!
Apr 6, 2009 at 11:28 PM
Hi stenson

From what I can understand, if you are going to to turn physics off then having the ball-box method won't really have any advantages. It will probably be easier to use a box and then getting the info from the collision response to adjust it.

It sounds like that if the physics is off, if something collides with something else it will continue moving through it, so you will have to do all the movement and adjustments by your self. ie a box wont move up a slope, it will move thrrough the slope, unless you change its position and angle to that of the slope manually.

Im not 100%, I havent tried it, but I presume thats how it will work with no impulses.
Apr 7, 2009 at 4:38 PM
Edited Apr 7, 2009 at 4:38 PM
ahh.. you make an excellent point Robert. In light of this I may actually use the physics and implement the technique you used in the post I linked to. Thanks for the input!