0
votes

I created a ball with friction 0.f and restitution 1.0, like this:

// Create shape definition and add to body
    b2FixtureDef ballShapeDef;
    ballShapeDef.shape = &circle;
    ballShapeDef.density = 1.f;
    ballShapeDef.friction = 0.f;
    ballShapeDef.restitution = 1.0f;
    //ballBodyDef.bullet = YES;
    _ballFixture = ballBody->CreateFixture(&ballShapeDef);
    // Give shape initial impulse...
    b2Vec2 force = b2Vec2(0, 1.2f);
    ballBody->ApplyLinearImpulse(force, ballBodyDef.position);

The ball bounces nicely off the walls when collision happened. But it will slide like on ice when collided with a gradual slope, like this:

Image of Demo

And the incline's physics properties are: Density:1 Friction:0 Restitution:1

How can I do to make the ball bounce away from the slope?

2

2 Answers

1
votes

If both surfaces have zero friction, there is no reason for the ball to "bounce" when it hits at an angle. Try giving both surfaces a little bit of friction.

0
votes

Try giving restitution to either ball or slope