Berhoh

Captain Toad

Oct 11th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1. void Update()
  2.     {
  3.         if (_camPointTimer>0.0f)
  4.         {
  5.             _toadControl.FreezePlayer(true);
  6.  
  7.             _camPointTimer -= Time.deltaTime;
  8.             if (_camPointTimer < 0.0f) _camPointTimer = 0.0f;
  9.  
  10.             _transform.position = _camPoint.GetCamPoint();
  11.             FocusObject.transform.position = _camPoint.GetFocusPoint();
  12.             _transform.LookAt(_camPoint.GetFocusPoint());
  13.         }
  14.         else
  15.         if (_enabled)
  16.         {
  17.             _toadControl.FreezePlayer(false);
  18.  
  19.             //SEND INPUT ACTIVITY INFO
  20.             if (Input.GetButton("Camera View Change") || Input.GetButton("Interact") ||
  21.                 Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0 ||
  22.                 Input.GetAxis("Camera Horizontal") != 0 || Input.GetAxis("Camera Vertical") != 0 ||
  23.                 Input.GetMouseButton(0) || Input.GetAxis("Camera Zoom") != 0)
  24.                 _gameManager.InputActivation();
  25.  
  26.             if (!_gameManager.InputActive())
  27.                 CameraAngle.x -= 0.0005f;
  28.  
  29.  
  30.             //CLOSE UP VIEW SWITCH
  31.             if (Input.GetButtonDown("Camera View Change"))
  32.                 CloseUpView = !CloseUpView;
  33.  
  34.             float viewChangeSpeed = 0.05f;
  35.  
  36.             //if in close up view, move focusobject to player object
  37.             if (CloseUpView && FocusObject.transform.position != _player.transform.position)
  38.                 FocusObject.transform.position = MoveToPoint(FocusObject.transform.position,
  39.                     _player.transform.position, viewChangeSpeed);
  40.  
  41.             //if not in close up view, move focusobject to original position
  42.             if (!CloseUpView && FocusObject.transform.position != LevelCenter)
  43.                 FocusObject.transform.position = MoveToPoint(FocusObject.transform.position,
  44.                     LevelCenter, viewChangeSpeed);
  45.  
  46.             //CHANGE ANGLES
  47.             CameraAngle.x += Input.GetAxis("Camera Horizontal") * CameraRotateSpeed * Time.deltaTime;
  48.             CameraAngle.y += Input.GetAxis("Camera Vertical") * CameraRotateSpeed * Time.deltaTime;
  49.  
  50.             //Mouse move
  51.             if (Input.GetMouseButton(0))
  52.             {
  53.                 CameraAngle.x += Input.GetAxis("Camera Horizontal Mouse") * CameraRotateSpeed * Time.deltaTime;
  54.                 CameraAngle.y += Input.GetAxis("Camera Vertical Mouse") * CameraRotateSpeed * Time.deltaTime;
  55.             }
  56.  
  57.             //Clamp y rotation
  58.             CameraAngle.y = Mathf.Clamp(CameraAngle.y, -0.15f, 1.5f);
  59.  
  60.             //ZOOM
  61.             if (Input.GetAxis("Camera Zoom") != 0)
  62.             {
  63.                 CameraDistance -= Input.GetAxis("Camera Zoom") * 0.5f;
  64.                 CameraDistance = Mathf.Clamp(CameraDistance, CameraZoomRange.x, CameraZoomRange.y);
  65.             }
  66.  
  67.             //Set camera transform
  68.             AdjustZoom(CameraDistance);
  69.  
  70.             //CAMERA AND FOCUS ROTATION
  71.             Vector2 angle = CameraAngle / Mathf.PI * 180;
  72.  
  73.             FocusObject.transform.rotation = Quaternion.Euler(
  74.                 0.0f,
  75.                 angle.x,
  76.                 angle.y);
  77.  
  78.             _transform.LookAt(FocusObject.transform.position);
  79.         }
  80.         else
  81.             _toadControl.FreezePlayer(true);
  82.     }
Add Comment
Please, Sign In to add comment