Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- if (_camPointTimer>0.0f)
- {
- _toadControl.FreezePlayer(true);
- _camPointTimer -= Time.deltaTime;
- if (_camPointTimer < 0.0f) _camPointTimer = 0.0f;
- _transform.position = _camPoint.GetCamPoint();
- FocusObject.transform.position = _camPoint.GetFocusPoint();
- _transform.LookAt(_camPoint.GetFocusPoint());
- }
- else
- if (_enabled)
- {
- _toadControl.FreezePlayer(false);
- //SEND INPUT ACTIVITY INFO
- if (Input.GetButton("Camera View Change") || Input.GetButton("Interact") ||
- Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0 ||
- Input.GetAxis("Camera Horizontal") != 0 || Input.GetAxis("Camera Vertical") != 0 ||
- Input.GetMouseButton(0) || Input.GetAxis("Camera Zoom") != 0)
- _gameManager.InputActivation();
- if (!_gameManager.InputActive())
- CameraAngle.x -= 0.0005f;
- //CLOSE UP VIEW SWITCH
- if (Input.GetButtonDown("Camera View Change"))
- CloseUpView = !CloseUpView;
- float viewChangeSpeed = 0.05f;
- //if in close up view, move focusobject to player object
- if (CloseUpView && FocusObject.transform.position != _player.transform.position)
- FocusObject.transform.position = MoveToPoint(FocusObject.transform.position,
- _player.transform.position, viewChangeSpeed);
- //if not in close up view, move focusobject to original position
- if (!CloseUpView && FocusObject.transform.position != LevelCenter)
- FocusObject.transform.position = MoveToPoint(FocusObject.transform.position,
- LevelCenter, viewChangeSpeed);
- //CHANGE ANGLES
- CameraAngle.x += Input.GetAxis("Camera Horizontal") * CameraRotateSpeed * Time.deltaTime;
- CameraAngle.y += Input.GetAxis("Camera Vertical") * CameraRotateSpeed * Time.deltaTime;
- //Mouse move
- if (Input.GetMouseButton(0))
- {
- CameraAngle.x += Input.GetAxis("Camera Horizontal Mouse") * CameraRotateSpeed * Time.deltaTime;
- CameraAngle.y += Input.GetAxis("Camera Vertical Mouse") * CameraRotateSpeed * Time.deltaTime;
- }
- //Clamp y rotation
- CameraAngle.y = Mathf.Clamp(CameraAngle.y, -0.15f, 1.5f);
- //ZOOM
- if (Input.GetAxis("Camera Zoom") != 0)
- {
- CameraDistance -= Input.GetAxis("Camera Zoom") * 0.5f;
- CameraDistance = Mathf.Clamp(CameraDistance, CameraZoomRange.x, CameraZoomRange.y);
- }
- //Set camera transform
- AdjustZoom(CameraDistance);
- //CAMERA AND FOCUS ROTATION
- Vector2 angle = CameraAngle / Mathf.PI * 180;
- FocusObject.transform.rotation = Quaternion.Euler(
- 0.0f,
- angle.x,
- angle.y);
- _transform.LookAt(FocusObject.transform.position);
- }
- else
- _toadControl.FreezePlayer(true);
- }
Add Comment
Please, Sign In to add comment