• Advertisement
Sign in to follow this  

XNA Camera Issues

This topic is 3411 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement