Sign in to follow this  
ChazH

XNA Camera Issues

Recommended Posts

ChazH    188
Hello, I have been playing around with a camera system that will rotate around a given target. I can get the camera to rotate around the object if it is not moving. Once the object moves, I can not get the object to rotate around the object. It will rotate and keep the target in view but wont rotate around the object. This might not sound like a good example but you can see what im talking about at my Blog. Here is a sample of my code for the camera movement *= (moveRate * timeDelta); rotationMatrix = Matrix.Identity; Matrix.CreateRotationY(MathHelper.ToRadians(cameraYaw), out rotationMatrix); if (movement != Vector3.Zero) { cameraPosition += movement; } Vector3.Transform(ref cameraPosition, ref rotationMatrix, out cameraPosition); Matrix.CreateLookAt(ref cameraPosition, ref cameraTarget, ref cameraUpVector, out view); The cameraTarget is the object.

Share this post


Link to post
Share on other sites
MJP    19753
After you've rotated the camera position (by transforming the position vector with the rotation matrix you create), add cameraTarget to the resulting position.

Also FYI there are tags you can use that will format source code properly for display in the forums. See the FAQ.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this