Camera rotation
Posted: Mon Dec 28, 2009 1:36 pm
Hello, i try yo adapt your demo script.
i can't do that my camera follow my character when it rotate on itself.
I want that the camera follow the back of my character when it rotate.
I try something like
Sometimes the camera rotate too fast or too slow and dont follow my character...
Anyway i think it's not the good way !
Thank you for some help
i can't do that my camera follow my character when it rotate on itself.
I want that the camera follow the back of my character when it rotate.
I try something like
Code: Select all
public void update(float dt, KeyboardState keyboardInput, GamePadState gamePadInput)
{
if (isActive)
{
//Note that the character controller's update method is not called here; this is because it is handled within its owning space.
//This method's job is simply to tell the character to move around based on the camera and input.
//Puts the camera at eye level.
Vector3 oldOff = cameraOffset;
cameraOffset.X = hero.entity.orientationMatrix.Forward.X * -1;
cameraOffset.Z = hero.entity.orientationMatrix.Forward.Z * -1;
camera.position = characterController.body.centerPosition + (cameraOffset);
//Change rotation of the camera
//Camera direction follow hero's direction
if (oldOff != cameraOffset)
{
camera.changeRotation(MathHelper.Clamp(hero.entity.orientationMatrix.Forward.X * -1 * characterController.rotateSpeed, -1.25f, 1.25f) / 10, 0);
}
Anyway i think it's not the good way !
Thank you for some help
