Reputation: 433
I am trying to wrap my head around this for quite some time now:
I have a kinematic RigidBody instance with a box shape. I have a static floor object (RigidBody instance with another box shape as well). The kinematic instance is the player object that should be able to move objects around, but the other objects shall not affect the player object in any way.
However, I also want the kinematic object to not go through walls or floors. I know that bullet does not allow kinematic objects to check for collisions with static objects. Or at least I think it does not.
I think my options are:
Creating a ghost object that always moves with the kinematic object and checks for collisions. I tried that but had severe performance issues whenever I updated the ghost object's position to its parent object's position. And for some reason the ghost object was always colliding with something?
Switch my kinematic object to a dynamic one. I tried this, too, but I do not know how to stop other objects from moving my player object around. And I also cannot get the player object to stop if WSAD is not pressed. It always 'slides' a bit (yes, I tried friction = 1). Sure I could set the linear velocity to 0 every time the WASD keys are not pressed, but this seems to affect the gravity as well, making my player float above ground instead of falling down. I also tried to set the damping factor to a high value, but this also affects world gravity causing the object to fall down more slowly...
My favorite option: since my kinematic RigidBody instance has a collision shape, there MUST be a way to call a method that "gets a list of intersecting shapes with collision normals and depths". Then I would iterate over that list every frame and use the collision normal and depth to reposition my player back up if it intersects the floor shape.
Before I tried 'Bullet', I did the collision test manually: First a broadphase axis sweep, then SAT intersection test for potential collision candidates. Then notifying the objects and giving them the colliding objects, collision normals and depths as parameters. I just need exactly this behavior :-).
Any help is hugely appreciated. How can I get this basic player movement to work?
I am using BulletSharp.
Upvotes: 1
Views: 1406
Reputation: 1164
What if you stick to #2, and change the mass ratio for your player, and the objects. Like increasing the player mass (and affecting forces) by ten folds, and decrease the other objects mass (and affected forces) by ten folds. This will surely make your player not move an inch if it is hit by small weighted boxes.
Second part is not clear why the friction is not working. Does the friction work for other gravity affected objects, or do they slide on slope as well?
Upvotes: 0