Jump to content
  • Advertisement
Sign in to follow this  

Rotating Player Mesh

This topic is 3180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I started using Ogre3D yesterday, and followed a bunch of tutorials, and actually managed to get a lot of stuff done. Due to it being forever since I did any type of math though, I have been getting stuck on some rather silly stuff. I am hoping someone wouldnt mind pointing out what I can change in this snippet to rotate my character 180 degrees. Right now when you click to move somewhere, the characters backwards (facing 180 degrees the wrong way, so hes basically moon walking)
Real CBasePlayer::facePoint(const Ogre::Vector3 &point)
   // Figure out the direction and distance to our target point from our position
   Vector3 direction = point - baseNode->getPosition();
   direction.y = 0;
   Real distance = direction.normalise();

   // Rotate our mesh towards our target point
   Vector3 meshOrient = meshNode->getOrientation() * Vector3::NEGATIVE_UNIT_Z;
   Quaternion quat = meshOrient.getRotationTo(direction);

   return distance;

Share this post

Link to post
Share on other sites
Don't be afraid to play around with the math. You only have a few operations going on there. If you need to reverse your direction, try reversing one of the math operations. There are a couple of very simple solutions, if you think about it.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!