Vehicle Control

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
schulzor2004
Posts: 29
Joined: Mon Jan 12, 2009 2:43 pm

Vehicle Control

Post by schulzor2004 »

Hi,

I have built up a skateboard with your vehicleController. Worked great! So I have one simple question: I want the skateboard to roll down a hill, but it should always stay in the same direction and it should always have the same direction (heading right). Here is a Video: http://www.youtube.com/watch?v=pozAAUNOkgY&hd=1

How can I manage this?

By the way: great forum, you always helped me!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle Control

Post by Norbo »

That project looks great!

One way to do what you want is to change the inertia tensor inverse on two of the axes so that it can only rotate around one (as if it were 2D):

Code: Select all

            Matrix inertiaTensorInverse = vehicle.body.localSpaceInertiaTensorInverse;
            inertiaTensorInverse.M21 *= 0;
            inertiaTensorInverse.M22 *= 0;
            inertiaTensorInverse.M23 *= 0;
            inertiaTensorInverse.M11 *= 0;
            inertiaTensorInverse.M12 *= 0;
            inertiaTensorInverse.M13 *= 0;
            vehicle.body.localSpaceInertiaTensorInverse = inertiaTensorInverse;
And then you'd need some sort of plane constraint to keep the skateboard on track. This could be a simple updateable that applies a force to the skateboard's center of mass based on how far it has diverged from the middle, a properly solved velocity constraint (a bit tougher), or you could just try setting the velocity to zero along the unwanted axis and keeping the position centered on the plane.

I've got a few more ideas that I can give when I get back if these don't get exactly the results you want (in regard to rotation).
schulzor2004
Posts: 29
Joined: Mon Jan 12, 2009 2:43 pm

Re: Vehicle Control

Post by schulzor2004 »

thank your very much, it works!
Post Reply