Advertisement
ChocoMan

Untitled

Sep 19th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. // In my ModelLoad class
  2. public void LoadContent(ContentManager content)
  3.         {
  4.             Model = content.Load<Model>(_modelName);
  5.             shiftLR = 0;
  6.             camHeight = 175f;
  7.             zoom = 250f;
  8.             camTarget = new Vector3(_modelPos.X, _modelPos.Y + camHeight, _modelPos.Z + -zoom);
  9.             camPos = new Vector3(shiftLR, camHeight, Zoom);
  10.         }
  11.  
  12. public Matrix getViewQ()
  13.         {
  14.             Matrix view = Matrix.CreateLookAt(CameraPos, CamTarget, Vector3.Up);
  15.             return view;
  16.         }
  17.  
  18. // In my Input class
  19. // Move Forward (bug when camera position (zoom) equals or exceeds original (_modelPos.Z) position
  20.             if (pController.IsButtonDown(Buttons.LeftThumbstickUp))
  21.             {
  22.                 SpeedX = (float)(Math.Sin(ModelLoad.ModelRotation)) * FWDSpeed;
  23.                 SpeedZ = (float)(Math.Cos(ModelLoad.ModelRotation)) * FWDSpeed;
  24.  
  25.  
  26.                 ModelLoad.camPos += Vector3.Forward * SpeedZ;
  27.                 ModelLoad.camPos += Vector3.Left * SpeedX;
  28.  
  29.                 ModelLoad._modelPos += Vector3.Forward * SpeedZ;
  30.                 ModelLoad._modelPos += Vector3.Left * SpeedX;
  31.             }
  32.  
  33.             // Move Backward (works perfectly)
  34.             if (pController.IsButtonDown(Buttons.LeftThumbstickDown))
  35.             {
  36.                 SpeedX = (float)(Math.Sin(ModelLoad.ModelRotation)) * backwardSpeed;
  37.                 SpeedZ = (float)(Math.Cos(ModelLoad.ModelRotation)) * backwardSpeed;
  38.  
  39.                 ModelLoad.camPos += Vector3.Backward * SpeedZ;
  40.                 ModelLoad.camPos += Vector3.Right * SpeedX;
  41.  
  42.                 ModelLoad._modelPos += Vector3.Backward * SpeedZ;
  43.                 ModelLoad._modelPos += Vector3.Right * SpeedX;
  44.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement