Sign in to follow this  

Rotating Player Mesh

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this