3

I wrote a player controller for my game that uses a rigid body to give the player physics. I set both restitution and friction to 0, and the mass to 80. My terrain has the exact same properties, just that the mass is also 0. Whenever the player falls from a great height, it bounces on the terrain surface a few times. This isn't really how I want my player to react. Is there a way to prevent this kind of behaviour?

Here is a video illustrating my problem. It is slightly laggy because I recorded it using QuickTime, but it should get the point across.

http://www.youtube.com/watch?v=2eQ1cj7hpWw

Nik
  • 1,033
  • 2
  • 11
  • 28

1 Answers1

6

You set restitution 0 and expect it to not bounce. But that small jump (comparing with height from which your felt) is coursed by solver when your body collides with earth. Solver applies certain impulse to resolve collision and stop your movement. Impulse is bit bigger then necessary to avoid situation when collision is not resolved.

You may consider to implement different simulation when your body is kinematic and not dynamic.

You will have to process collisions and movements manually but you will have full control on how you wish your body to move.

Max
  • 6,286
  • 5
  • 44
  • 86
  • I just found out about `setContactProcessingThreshold(btScalar(0.0));` which kind of removes some of the jerkiness. Is there really no other way? – Nik Sep 16 '12 at 20:45
  • Setting Threshold for one for few objects may work or may not and course jitter. You should not definately set it for all objects. It may work if you have 1 object and terrestrial but may course problems (jittering, wall penetration) if you will have more colliding objects. I would use setContactProcessingThreshold with value always more then zero defining scale of threshold for different objects. Threshold is implemented to make simulation for stable. – Max Sep 16 '12 at 21:02
  • Do you think a value of 0.01 would not be too small? And are you basically saying that if i set everything to 0.0 i will get wall penetration issues? – Nik Sep 16 '12 at 21:07
  • I just tried it and you were right. Can you create custom solvers in Bullet? – Nik Sep 16 '12 at 21:17
  • physics engine detects collisions and use solver to solve collisions. It is very complex to make a good solver. – Max Sep 16 '12 at 21:33
  • I will look into the Kinematic Character Controller and see how that works out – Nik Sep 17 '12 at 14:18
  • BTW set restitution for terrestrial (surface) to 0 as well. – Max Sep 17 '12 at 14:58
  • `I set both restitution and friction to 0, and the mass to 80. My terrain has the exact same properties, just that the mass is also 0.` - that means that the terrain has 0 restitution. – Nik Sep 17 '12 at 18:42
  • Right. I noticed in my project the wall had default restitution. I thought about your case. – Max Sep 17 '12 at 20:17