Apply force in local direction

Software: Away3D 4.x

Oscar, Newbie
Posted: 18 April 2012 07:46 AM   Total Posts: 5

Hello!

I’ve just started out with AwayPhysics and I’m stuck with a probably simple problem. I want to make a simple cylinder rigid body move with my arrow keys, preferably by applying forces in a correct way.

I’m rotating the cylinder like so:

/*When right key is held */
_playerRotation += 3
_playerBody
.rotation = new Vector3D(0_playerRotation0); 

I apply force to move my cylinder forward like:

/* When forward key is held */
_playerBody.applyCentralForce(new Vector3D(0020)); 

The issue is that when the force is applied it simply moves in the Z-axis of the world, I want it to be pushed in the local rotation direction of the cylinder! How would I go about making this happen?

Thanks!

   

tsu, Newbie
Posted: 18 April 2012 08:37 AM   Total Posts: 2   [ # 1 ]

Well, im not an expert but one way would be instead of

_playerBody.applyCentralForce(new Vector3D(0020)); 

to use this:

var force :Vector3D _playerBody.front;
force.scaleBy(20);
_playerBody.applyCentralForce(force); 
   

Oscar, Newbie
Posted: 23 April 2012 03:57 PM   Total Posts: 5   [ # 2 ]

Ah, interesting. Thanks grin Will try it out.

   

Oscar, Newbie
Posted: 24 April 2012 07:20 AM   Total Posts: 5   [ # 3 ]

That worked great, thanks again.

As a follow up question: Do you know how to apply some sort of max speed to limit the forward movement etc?

   

JakobWagner, Newbie
Posted: 18 December 2012 10:47 AM   Total Posts: 5   [ # 4 ]

Hi,

Did you figure out the max speed thing?

Jakob

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X