Advice on making a wall hugging vehicle

User avatar
sinoth
Posts: 13
Joined: Tue Apr 07, 2009 8:27 pm
Location: USA

Advice on making a wall hugging vehicle

Post by sinoth »

Heya all, still playing around with this problem but I'd like some input if possible :) I've got this dynamic spherical object that serves as a vehicle the player can control, and a big static cube floating in the air. I'd like the player to be able to jump onto this cube and 'stick', and be able to move around on whatever face they land on. Being able to fairly smoothly transition from one face to another (90 degree change) would be nice also but not as crucial.

At first, I tried to zero the linear and angular velocity upon impact and setGravity to (0,0,0), but this didn't work because of how the solver works... I'm assuming what happens is the object collides, penetrates slightly, I zero the linear/angular velocity, and then the solver applies an impulse to counteract the penetration and the sphere is in motion again. No stick.

The idea I'm running with now is to store the normal of collision upon impact and use a btGeneric6DofConstraint to restrict linear movement to a 2D plane. This isn't working very well either because of the penetration issue... if I set the constraint when the sphere is still slightly inside the cube, then you can't move at all. If I set the constraint too late then the sphere is already out of contact with the cube. Plus, the collision between a sphere and cube is one tiny point and it seems like it's too easy to lose this contact (which breaks the 'sticky' mode).

Any suggestions on how to approach this problem?
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: Advice on making a wall hugging vehicle

Post by ola »

How about setting the direction of the sphere's gravity to be the negative of the surface normal of the object you collide with at the newest contact point position? Then your sphere would fall towards the surface you contacted. I think you could traverse most object surfaces with this method, except maybe those 90degree corners. Maybe you could smoothen the gravity vector when near an edge so that it would behave like the edges were rounded.

Additionally, you could reset the gravity to the normal (down) direction if you haven't had any collisions for some time (like 1 seconds), to make things a bit more robust.

Cheers,
Ola