# 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;
meshOrient.normalise();
Quaternion quat = meshOrient.getRotationTo(direction);
meshNode->rotate(quat);

return distance;
}


##### 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.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978622

• 9
• 14
• 12
• 10
• 12