VehicleControl stuck in wall

I’ve followed the physics vehicle tutorial and made my own vehicle by adapting it. However when I hit a wall (even gently) I get stuck in it:

The very corner of the pink box is just beyond the wall, and when I try to move back or forward the vehicle just slowly rotates around the point that is inside the wall.

Has anyone else had this and knows how to fix it?

I’ve noticed it is only the back end of the vehicle that can get stuck, if that’s any help. Managed to get it stuck in the floor too.

Large triangles don’t make good collision areas.

1 Like

Hi, thanks for the help Normen. I have altered the collision model, and it has helped marginally.

It sometimes is now easy to get unstuck by holding accelerate or reverse for perhaps 4 seconds, but still gets stuck extremely often, and occasionally is permanently stuck. The collision model is literally just a box the vehicle is dropped into. I tesselated it to make the triangles smaller.

Is there anything else I can do to help with this? I really love the way the vehicle control handles and it would be great to have in my game.

how is the friction of that box & wall?

Also wich wheels do have power? All or only a few?

1 Like

The friction of both is 0.5f. I just tested with one and both at 0 friction, same problem.

I’m using the VehicleControl.accelerate(float) so I believe all my wheels are powered. I printed wheelget.DeltaRotation() to see how they are rotating when it gets stuck, and all 4 wheels are barely rotating when stuck.

You could try to do a part of the force with applyForce, thats moe hack but might be enough to unsttuck
maybee combined with a detection that the car is not moving when pressing keys

1 Like

Ok I’m gonna give this a try now, thanks for the suggestion.

I don’t want to start yet another thread for this one, so when creating a CompoundCollisionShape, say out of two boxes, is it then possible to move one of the shapes making up the compound shape independantly of the other (and collisions working)? I want to use this for my forklift truck - 1 for the collision box as seen in the image, and another smaller for the lifter at the front. I have tried this with a Kinematic rigidbodycontrol, but it did not work very well.

@normen said: Large triangles don't make good collision areas.
could someone explain why this is? is it a bug in bullet or do all physics engines deal with this?

I managed to solve the issue with your suggestion Empire Phoenix. I calculated if it was stuck, then bumped it in the correct direction and translated it upwards, if it was still stuck I repeat with larger values, works nicely enough. Thank you.

I’m also be interested in knowing about large triangles (never noticed a problem before), and if anyone knows about moving one part of a compound collision shape that would be amazing.

@JESTERRRRRR said: if anyone knows about moving one part of a compound collision shape that would be amazing.

There’s actually a forklift demo in the bullet physics code.

Maybe that can give some hints.

1 Like

I guess the triangle stuff is based on the range the algorithms are optimized for

In case anyone else eventually has this problem, the final solution was to track the distance the vehicle had travelled since i last pressed the button to accelerate or decellerate, if it was < 0.1, I would begin increasing the acceleration value by 20*stuckCount, were stuckCount is increased every update. This is the smoothest solution I can find. Also increasing restitution to 1 helped if you dont mind the other effects.

Thanks Johan, I suppose I’ll have to use a joint based on how they do it. I’ll start preparing my support thread for that now…

RigidBodyControl x.setMargin(0.2f);
or use a denser collision mesh. I had similar problems getting a cylinder to collide with stuff. If the side of the cylinder hit it would clip through and get stuck. The margin helped a little but the problem went away when I used a scaled capsule instead (more triangles)