Jump to content
  • Advertisement
Sign in to follow this  
Muzzy A

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.

If you intended to correct an error in the post then please contact us.

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.

 

 

Share this post


Link to post
Share on other sites
Advertisement

//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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!