I'm developing a 2D platformer, although this question could probably apply to just about any 2D type physics; What is the equation for friction? I have sort of a hacky type of friction set up in my game currently, but I'm not satisfied with it because it doesn't account for all forces being applied to my character outside of whatever forces he's generating himself.
There's two types of friction, static friction and kinetic friction. Static friction is the friction that needs to be overcome to get something moving from rest. You'll notice when pushing a box across the floor, it can often take more force to get it moving than to keep it moving. Or you'll be applying force and it will jolt forward and you'll have to not push as hard. That jolt forward is the point when static friction is overcome and you're dealing with kinetic friction. Kinetic friction is almost always (always?) less then static friction.
Either way, friction is a force just like acceleration. It's calculated based on the normal force of the objects and coefficent of friction (µ).
This free body diagram shows a few forces.
So when the force of friction and the force being applied are equal, the object will not accelerate. So if it's stopped, it's not going anywhere and if it's moving it'll continue to move at that speed.
So you're going to want to collect some information to simulate friction.
Then you can simply calculate the force of friction with the following:
friction = µ • normalForce
When you're summing up your forces you include this force. If you have no other accelerations, then your friction is going to be the only force, and will slow your object down.