Jump to content

Turning an Model to face the direction it is moving


Eric
 Share

Recommended Posts

Yes I'm looking at those commands but what I can't figure out is what to put in the CalcbodyOmega Rotation field .... If I am applying a force and my Model starts to move, how do I know what information to enter in the rotation vector to make sure it points in the direction of movement?

 

Thanks,

Eric

Link to comment
Share on other sites

The easiest way is to have two TPivot's that you use to get the desired rotation.

Position one pivot right where your model is and the other at the place you want to look at.

Let the first pivot point at the second one and then get the rotation from your first pivot.

Now use that rotation in CalcBodyOmega and you are done.

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

Is this a character walking? If so, I would use the character controller.

 

If the model only rotates on the XZ plane, an ATan2 operation will get the yaw angle from a normalized vector.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Ok once I have the Yaw Angle.. Which I Do... How do I use the AddBodyTorque and CalcBodyOmega to turn the Model only on the Y Axis to face the calculated Yaw Angle...

 

Nothing I seem to Try Works

float Angle=atan2(Position.X-PreviousPos.X,Position.Z-PreviousPos.Z) * 180 / PI;
AddBodyTorque(Model,CalcBodyOmega(Model,Vec3(0,Angle,0))*ModelMass,0);

 

This is my latest try...but I'm getting something wrong.

 

Is this the right way to Apply Torque only on the Y axis?

 

Thanks,

Eric

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...