# Why are my Box2D wheels slipping on ground?

| | August 10, 2015

I have a car, set up in Box2D as a rectangle connected with two wheels using `WheelJoint`s:

The wheels are defined as follows:

``````    FixtureDef wheelFixtureDef = new FixtureDef();
wheelFixtureDef.density = 1.f;
wheelFixtureDef.shape = wheelShape;
wheelFixtureDef.friction = 0.98f;
wheelFixtureDef.restitution = 0.3f;

// wheel joint (only one of the wheels has the motor enabled)
wheelJointDef.dampingRatio = 0.9f;
wheelJointDef.frequencyHz = 20.0f;
wheelJointDef.motorSpeed = 15.4f;
wheelJointDef.maxMotorTorque = 100.f;
``````

And the ground:

``````    FixtureDef groundFixtureDef = new FixtureDef();
groundFixtureDef.density = 0.f;
groundFixtureDef.friction = 1.0f;
``````

Still, when trying to climb that hill in the picture, the wheels reach a stage where they just keep slipping, and it slides back down.

Why does it slip even though the friction coefficients are set high? How can I make it overcome that hill?

## 2 Responses to “Why are my Box2D wheels slipping on ground?”

1. Friction coefficient is equal to tangent of the maximum angle before the item will slide.

You need to set coefficient greater then 1. There is a function in the Settings class – MixFriction. It’s used to calculate the friction coefficient between surfaces, by default it’s a geometric mean, you can change this too.

2. Your car is slipping for the same reason that a car hanging up-side down, riding the ceiling, with 100% friction would slip. 100% friction roughly means that 100% of the force exerted via the wheels on the terrain is used to counter movement perpendicular along the normal of the terrain. But this force still isn’t enough to counter the force of gravity. This happens when the forces working up-on the vehicle that direct downwards are larger than those pointing towards the ground. You’ll probably see wheel slippage starting from hills with a 45 degree slope.

You could solve this by ‘faking’ gravity always having it point in the opposite direction as the normal of the terrain segment the vehicle is currently driving on.

• ### How To Submit a iPhone App to the Appstore

by on July 5, 2012 - 0 Comments

The process to develop an iPhone app is not as hard as one might think. The entry into the app store has been opened up to many new types of develope...

• ### Develop iphone Apps on Windows

by on March 7, 2011 - 13 Comments

Top 10 Ways to Develop an iphone/ipad app without a Mac #1. Code in Java For Java developers, there is a workaround: XMLVM. XMLVM cross-compiles byte...

• ### Iphone Android App Ideas: Getting Started

by on March 19, 2011 - 3 Comments

Smartphone Application Ideas: Getting Started Smartphone application developers are constantly on the move. And since overzealous developers stick ...