# Camera rotation is a little off

This topic is 2033 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();

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

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013607
×