XNA Camera Issues

Started by
0 comments, last by MJP 15 years, 5 months ago
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.
Thank you,
Chaz
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.

This topic is closed to new replies.

Advertisement