• 13
• 15
• 27
• 9
• 9

Camera rotation is a little off

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

Recommended Posts

Hey, I'm trying to get my camera to work right. But I'm having trouble and I can't figure out why.

I've even looked up tutorials and basically copy-pasted the code from the tutorials and it still wont work.

But, I'm trying to do it the way I learned in school.


Matrix camRot = Matrix.CreateRotationY(mouseX * dt) * Matrix.CreateRotationX(mouseY * dt);

// Rotate like this?
cam *= camRot;

// Fix up the broken axis's
cam.Right = Vector3.Cross(cam.Forward, Vector3.Up);
cam.Right.Normalize();

cam.Up = Vector3.Cross(cam.Backward, cam.Right);
cam.Up.Normalize();

//cam.Forward = Vector3.Cross(Vector3.Up, cam.Right);
//cam.Forward.Normalize();


This code works perfectly fine for rotating left and right, but when I rotate up and down, everything is skewed and awkward looking.

cam.Backward?

Share on other sites

//cam.Forward = Vector3.Cross(Vector3.Up, cam.Right);
//cam.Forward.Normalize();

This help?

cam.Forward = Vector3.Cross(cam.Up, cam.Right);
cam.Forward.Normalize();

Share on other sites

//cam.Forward = Vector3.Cross(Vector3.Up, cam.Right);
//cam.Forward.Normalize();

This help?

cam.Forward = Vector3.Cross(cam.Up, cam.Right);
cam.Forward.Normalize();

already tried that, made it 1000 times worse, everything basically disappeared.

And the backward thing, i know it's weird, but forward put me facing the opposite direction i actually wanted to be

The way You currently see it,it seems like it's trying to rotate around the world's x axis instead of it's local, but at the same time tries to do it on the local, so i get these really awful and awkward camera angels

But like i said, looking left and right works absolutely fine.

Edited by Muzzy A