Balls goes slightly into ground, then bounce up repeatedly

Post Reply
TheNess
Posts: 5
Joined: Sun Jul 30, 2017 7:09 pm

Balls goes slightly into ground, then bounce up repeatedly

Post by TheNess »

Hi all, new in this forum :)

I created a world with two objects - a collision object with height map and a sphere. The sphere is affected by gravity.
While collision seems to be overall working, I'm having a problem that the sphere is sinking into the ground, then bounce back up to prevent the penetration, which causes the ball to bounce endlessly.

Please see this video if it wasn't clear:

https://youtu.be/UBwQzbJVH_M

Eventually it stops btw. After a long while.

Some technical info:

1. I'm using BulletSharp (the C# port of Bullet3d) version 0.9.0.
2. The terrain map physics is not a rigid body, its a CollisionObject with shape set to a HeightfieldTerrainShape. While not shown in the video, if I render the physical world the heighfield map matches the terrains perfectly, so its data is OK I guess.
3. The sphere a RigidBody with SphereShape attached to it. Most of its properties are defaults, it has mass and intertia of 10f, friction of 1f. I tried playing with Restitution but it didn't help.
4. My emulate step looks like this: _world.StepSimulation(timeFactor, MaxSubStep, FixedTimeStep); - timeFactor is float, the time between previous and current frame in seconds. MaxSubStep is 14, FixedTimeStep is 1/60, but I tried playing with those values and it doesn't change much.

While in the vid the FPS are 400~ due to recording, usually its a lot more, around 1500+. Also note that I tried making the sphere smaller, just to see what would happen, and it goes through the floor, which makes me feel like the emulation don't run as often as it should.

What am I doing wrong here?
Thanks!
TheNess
Posts: 5
Joined: Sun Jul 30, 2017 7:09 pm

Re: Balls goes slightly into ground, then bounce up repeated

Post by TheNess »

Answering self for future seekers: this happened because the min and max height of the heightfield shapes were not set properly..
Post Reply