Ok, having tested the above solution for a while, I can confirm it doesn't really work. The problem is that once the moving object collides with the character controller, internally it is likely to be stopped, and will never collide again.
E.g.
- Wall is moved with dynSetLinearVelocity() every loop, to ensure it's speed is constant and collisions don't affect it at all.
- When it first hits the character controller a collision is detected. You can then reposition the character controller using the method described above.
- At this point though, the internal system seems to stop the actor (reduce velocity to 0).
- Continuing to set the velocity every loop seems to have no effect. It's as if the engine detects the wall is touching the immovable character controller, and therefore ignores the velocity.
One solution is to set the character controller further away on each collision. This is more reliable, but causes a jumping stuttering effect as the controller jumps away from the moving object. It's still not reliable either. It's still possible for the object to touch the controller and the collision not to be detected and for it's speed to be set to 0, or for the collision to be detected but it's speed to be reported as 0.
It's starting to annoy me really! I would've thought it'd be a really common feature and would therefore be easy to implement with some provided functionality, but apparently not.
The only other solution I can think of is the following:
- Create a capsule object with a radius greater than the character controller
- Freeze all rotations
- Put it in it's own group and turn off collision with every other group, except your moving objects
- Ensure the character controller can't collide with it
- Set up contact reports between this capsule and the moving objects
Then ...
- Every loop, position the capsule on the character controller and set it's velocity to the character's velocity.
- Check for collision flags between the capsule and moving scenery
- If there is a collision, the capsule will have been moved automatically by the physics engine.
- Reset the character controller onto the capsule's position
That's the only solution I have left, and I really don't like it. I think it's horrible and messy.
I'm going to do a bit of googling and see if I can turn up something else and will report back.