Guest User

Untitled

a guest
Jan 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. public static void UpdateWithMouse() {
  2.             //// vars ////
  3.             float   minY,
  4.                     maxY,
  5.                     focusAngle = Player.FocusAngle,
  6.                     focusToMinY,
  7.                     focusToMaxY,
  8.                     mouseX = Input.GetAxis("Mouse X"),
  9.                     mouseY = Input.GetAxis("Mouse Y"),
  10.                     lookSpeed = GameProperties.LookSpeed,
  11.                     angleX,
  12.                     angleY;
  13.             //// work ////
  14.             // assign current rotation limits
  15.             if(Player.CurLocation.UseRotLimits) {
  16.                 minY = Player.CurLocation.RotLimits.z;
  17.                 maxY = Player.CurLocation.RotLimits.w;
  18.             }
  19.             else {
  20.                 minY = GameProperties.RotMinY;
  21.                 maxY = GameProperties.RotMaxY;
  22.             }
  23.             // assign 'focusTo' vars
  24.             focusToMinY = focusAngle - minY;
  25.             focusToMaxY = focusAngle - maxY;
  26.             // find angleX & angleY
  27.             angleX = mouseX * lookSpeed;
  28.             angleY = mouseY * lookSpeed;
  29.             angleY = Mathf.Clamp(angleY, focusToMinY, focusToMaxY);
  30.             // rotate Focus around player
  31.             Player.Focus.RotateAround(Player.Pos, Player.Right, angleY);
  32.             Player.Focus.RotateAround(Player.Pos, Player.Up, angleX);
  33.             // make Player look at his FocusPoint
  34.             Player.Obj.LookAt(Player.FocusPos);
  35.         }
Add Comment
Please, Sign In to add comment