Top-down object movement

Post Reply
chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Top-down object movement

Post by chadberk »

If I was looking at a btRigidBody from top down and I wanted to have the movement be so that when I press forward it will always go in its forward direction, even after I turn it, how would I apply forward movement and rotation?

For direction it appears that I would use applyCentralForce, what what force? Is there a way to apply the forward direction as a force?
For rotation would it be as simple as just rotating the transform?
chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Re: Top-down object movement

Post by chadberk »

Am I missing any information that may provide assistance with my question?
chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Re: Top-down object movement

Post by chadberk »

Is there anyone that could help me with this?
harrybro
Posts: 1
Joined: Thu Oct 25, 2012 6:12 am

Re: Top-down object movement

Post by harrybro »

what type of help you want.
chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Re: Top-down object movement

Post by chadberk »

harrybro wrote:what type of help you want.
With my original question, or if my original question is missing information, why information is it missing?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Top-down object movement

Post by Erwin Coumans »

The 'forward' direction you refer to is likely one of the local principal axis, such as the X, Y or Z axis.

You can use btVector3 localXdir = rigidbody->getWorldTransform().getBasis().getColumn(0); to get the local x axis,
use 1 or 2 for Y and Z.

Attached is a simple BasicDemo replacement, just unzip and copy the files over the existing demo in Bullet/Demos/BasicDemo and use the cursor keys to move around.
The sample is too simple to be practical, but it gives you an idea about movement.

Thanks,
Erwin
Attachments
BasicDemo.zip
(4.27 KiB) Downloaded 589 times
Post Reply