Sign in to follow this  

Little Help Needed with an FPS Camera (C#)

This topic is 3574 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 guys, or girls (if you happen to be one :] ) Can anyone spell out exactly how the formulas should be for calculating cameraPosition and cameraLookAt in C# (using XNA 2.0) while dealing with a First Person Shooter style camera. What i'm looking for in regards position is how to get the values added to the Vector3's X and Z values (Y is up) in order to allow movement. And as far as the lookAt is concerned, how to get smooth movement AND start off actually looking at the test model at 0,0,0. I have to go searching with the camera in order to find the dang model! Any and all help is appreciated. Thanks people! Oh, one more thing... Is there any way to draw a 3D line between two Vector3 points? Like showing up a bullet's vector line between target and gun barrel? Thanks again M@t.

Share this post


Link to post
Share on other sites
For line drawing, you can use something like:


device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, verts, 0, verts.Length, indices, 0, points.Length-1);


Of course you'll have to create the "VertexPositionColor[] verts;" and "short[] indices;" arrays and call this between a typical Effect.Begin() / Effect.End() pair.



For manual camera control, try experimenting with a Matrix's Up, Right, Forward and Translation properties.

Share this post


Link to post
Share on other sites

This topic is 3574 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.

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