Simulating a continuous track / escalator

mdias
Posts: 12
Joined: Thu Jun 28, 2012 2:21 pm

Simulating a continuous track / escalator

Post by mdias »

Hello

I have a box, and would like one of it's faces to act like a tank's continuous track so that if it falls on the ground with that face, it will begin to slide in a direction.

How could I implement this?

Thanks in advance
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Simulating a continuous track / escalator

Post by Erwin Coumans »

You could implement this using friction with a target velocity. There are two issues:

1) set a target relative contact motion, using a contact callback, for the contact point set m_contactMotion1 and/or m_contactMotion2, and the friction directions m_lateralFrictionDir1 and/or m_lateralFrictionDir2.

See Bullet/Demos/MultiMaterialDemo for an example of a contact callback.

2) find out if the collision happens on that particular face. You could use some heuristic checking if the contact point normal is similar to the face normal, using a dot product.

Hope this helps,
Erwin
mdias
Posts: 12
Joined: Thu Jun 28, 2012 2:21 pm

Re: Simulating a continuous track / escalator

Post by mdias »

Works great.

However it appears in some cases the friction info is getting cached somehow and the object gets stuck, not responding to variations in lateral friction. Clearing the relevant overlapping pairs within updateAction() solves it, though it seems more like a workaround...