This project has moved and is read-only. For the latest updates, please go here.

Question about some physics

Topics: Developer Forum, User Forum
Mar 11, 2009 at 3:18 AM
ive been using farseer for a little while now but now im attempting to do something like a platformer test thing

and i have 2 problems

the first is i wanted to know what these variables are and what good values are for them my smallest object is about 48*48 pixels in size and never moves more than say 15 pixels per second

So what are these and what are good values for them or how can i determine good values for them

geom.RestitutionCoefficient = from what i can tell / documentation it is basicly the amount of momentem that gets reflected
geom.FrictionCoefficient = the amount of friction from 0% to 100%
body.RotationalDragCoefficient = the resistance to rotate??
body.QuadraticDragCoefficient = have no idea
body.LinearDragCoefficient = have no idea

PhysicsSimulator.BiasFactor = have no idea
PhysicsSimulator.AllowedPenetration = i know what this is but dont know what i should really set it too
PhysicsSimulator.Iterations = not really sure mabey makes the physics update # times per frame???

any help on what these are and good values for them would be very helpful

problem two

when i stack objects ontop of each other 48*48 boxes and 64*64 boxes
they always jitter and can even fall into each other how do i solve this

i use the pyramid out of the demos and when its over 8 high they can fall into each other
and any more than 2-3 high they move randomly from left to right

i understand that this may be imposible to correct 100% but what can i do to reduce it (i had a try of what the documentaion said but didnt really do much so mabey im doing it wrong ) has anyone got any tricks???

Mar 11, 2009 at 9:10 AM
Part 1:
geom.RestitutionCoefficient =for really bouncy stuff (like trampolines), set it above one. For soft stuff, set the coefficient low (like 0.1 or something). foryour average
geom.FrictionCoefficient = This is useful for stuff like making ice or sticky surfaces.
body.RotationalDragCoefficient = It controls rotational resistance. If you don't want an object to rotate, you could turn this up to float.PositiveInfinity (i think).
body.QuadraticDragCoefficient = Similar to linear drag coefficient, but applied differently. I think it is useful if you have high speed objects and want them to have a problem going past a certain speed.
body.LinearDragCoefficient = This controls the "thickness" of the "medium" that the object is travelling through. It essentially applies a force that opposes the current speed, with a magnetude that corresponds to the current speed.

PhysicsSimulator.BiasFactor = I'm not sure what this is.
PhysicsSimulator.AllowedPenetration = I'm not sure what this is.
PhysicsSimulator.Iterations = This in general should be left where it is unless you have sim issues (like lots of interpenetration or something).
Part 2:
I don't have anything but other people do im sure.
Mar 11, 2009 at 9:33 AM
geom.RestitutionCoefficient - This is the bounciness of objects. The amount it bounces up after a fall to the ground.
geom.FrictionCoefficient - The amount of friction on the object. Friction is between 2 materials and thus you will need to adjust both the friction of the geometry and the object the geometry collides with.
body.RotationalDragCoefficient - Yep, you got it right. It's the amount of drag on the rotation. Said in another way: it's the amount (value) taken of the rotational speed.
body.QuadraticDragCoefficient - This is the drag, but in it's quadratic form.
body.LinearDragCoefficient - This is the drag applied to the velocity of the object. Sort of like airdrag.

PhysicsSimulator.BiasFactor - This is used with the normal velocity bias. I'll write about this in the manual at some point.
PhysicsSimulator.AllowedPenetration - The amount of penetration that is allowed when two geometries collide.
PhysicsSimulator.Iterations - The amount of iterations taken on each update. The number of times the joints are updated and the number of times the arbiters are applied impulse. Lower iterations improve performance but accuracy suffers.

I will make a note about this and make sure the manual (and code) contains this info in the future.
Mar 11, 2009 at 10:20 AM
in our platformer we circumvent the physics for the character movement similar to the approach displayed here:
it is very hard to find the right friction and drag values for a platformer. you need friction in order to prevent your character from slipping down even the smallest slops. as soon as you jump however, the character moves very fast because the drag is much, much lower than friction.
Mar 11, 2009 at 7:58 PM
For my platformer, instead of having friction slow the player down when he is on the ground, I just check the linear velocity Y component. If he is on the ground, his Y component should be very small. I simply apply a force to the left if he is moving right, and a force to the right if he is moving left, slowing him down.
Mar 11, 2009 at 11:11 PM
@Shpaidaman: uh, isn't that basically drag? (also, did you see my bug reports in your game thread?)