i just created a third person camera for my project.
this is my source:
the problem is, if i move the mouse (to rotate the player) the camerarotation is wrong and it warps.
Code: Select all
void Player::Update(CapInput* Input, float Time)
{
Ogre::Vector3 Direction = MainNode->getOrientation()*Ogre::Vector3::NEGATIVE_UNIT_Z;
Direction.normalise();
Ogre::Vector3 Movement;
Movement = Vector3(0,0,0);
mAnimationState->setEnabled(false);
if(Input->Up)
{
Movement = Direction;
}
if(Input->Down)
{
Movement = -Direction;
}
if(Input->Right)
{
Movement.z = Direction.x * -1;
Movement.x = Direction.z;
}
if(Input->Left)
{
Movement.x = Direction.z * -1;
Movement.z = Direction.x;
}
if(Movement.x == 0 && Movement.z == 0)
{
mAnimationState = PlayerEntity->getAnimationState( "Idle1" );
}
else
{
Movement = Movement * Time * mWalkSpeed;
MainNode->translate(Movement);
mAnimationState = PlayerEntity->getAnimationState( "Walk" );
}
MainNode->yaw(Input->mRotX);
mAnimationState->setLoop( true );
mAnimationState->setEnabled( true );
mAnimationState->addTime(Time);
}
and this happens if i move the mouse:
http://img110.imageshack.us/my.php?imag ... leroe8.jpg
anybody an idea what i have to change, that the camera rotates right with the body? the body rotation is imo right.
Eldarion