Jump to content
  • Advertisement
Sign in to follow this  
bader51

Orbital camera help XNA

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

Im just learning XNA and im making a game where i need the camera to orbit about 100 points up and 80 points behind a point on the ground. I also need to be able to move the camera. The code i have so far doesnt work very well, i can move the camera left right up and down fine but when i go to rotate the camera around the point it doesnt orbit the way i want it to. Heres the code: Public Overloads Overrides Sub Update(ByVal gameTime As GameTime) 'MOVE If Keyboard.GetState.IsKeyDown(Keys.Left) Then Dim CameraRot As Matrix = Matrix.CreateRotationY(Rotation) Dim addvec As Vector3 = Vector3.Transform(New Vector3(1, 0, 0), CameraRot) Position += addvec LookAt += addvec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If If Keyboard.GetState.IsKeyDown(Keys.Right) Then Dim CameraRot As Matrix = Matrix.CreateRotationY(Rotation) Dim addvec As Vector3 = Vector3.Transform(New Vector3(1, 0, 0), CameraRot) Position -= addvec LookAt -= addvec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If If Keyboard.GetState.IsKeyDown(Keys.Up) Then Dim CameraRot As Matrix = Matrix.CreateRotationY(Rotation) Dim addvec As Vector3 = Vector3.Transform(New Vector3(0, 0, -1), CameraRot) Position -= addvec LookAt -= addvec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If If Keyboard.GetState.IsKeyDown(Keys.Down) Then Dim CameraRot As Matrix = Matrix.CreateRotationY(Rotation) Dim addvec As Vector3 = Vector3.Transform(New Vector3(0, 0, -1), CameraRot) Position += addvec LookAt += addvec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If 'ROTATE If Keyboard.GetState.IsKeyDown(Keys.A) Then 'UP 100, Rotate, Back 5 Rotation += 0.01 Dim TransVec As Vector3 = Vector3.Transform(LookAt, Matrix.CreateTranslation(0, 150, -100) * Matrix.CreateRotationY(Rotation)) Position = TransVec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If If Keyboard.GetState.IsKeyDown(Keys.S) Then Rotation -= 0.01 Dim TransVec As Vector3 = Vector3.Transform(LookAt, Matrix.CreateTranslation(0, 150, -100) * Matrix.CreateRotationY(Rotation)) Position = TransVec View = Matrix.CreateLookAt(Position, LookAt, New Vector3(0, 1, 0)) End If MyBase.Update(gameTime) End Sub My game is written in vb.net but it shouldnt be too hard to figure out whats wrong with it, any help would be awesome!!!

Share this post


Link to post
Share on other sites
Advertisement
http://www.gamedev.net/community/forums/topic.asp?topic_id=490345

^ Try that thread.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!