void Update() { // Figure out how far back we need to be to see the camera // Look at the center point of the tree // Let the player rotate horizontally and vertically around the tree Vector3 plantCenter = _plantBoy.Center; // Rotation Quaternion prevRotation = transform.rotation; transform.LookAt(plantCenter, Vector3.up); transform.eulerAngles = prevRotation.eulerAngles.SetY(transform.eulerAngles.y); Quaternion desiredRotation = transform.rotation; transform.rotation = Quaternion.Lerp(prevRotation, desiredRotation, Time.deltaTime * _lerpLookAtSpeed); float rotateSpeed = _hasControl ? (_rotateSpeed * Input.GetAxis("Horizontal") * _controlAmount) : _autoRotateSpeed; rotateSpeed *= Time.deltaTime; transform.RotateAround(plantCenter.SetY(transform.position.y), Vector3.up, rotateSpeed); // Zoom float normalizedBoundsSize = _plantBoy.renderer.bounds.size.magnitude / _maxBoundsMagnitude; float sizeToDistanceAlpha = _boundsSizeToViewDistanceMap.Evaluate(normalizedBoundsSize); Vector3 zoomDirection = (transform.position - plantCenter).SetY(_heightOffset).normalized; _targetPosition = plantCenter + zoomDirection * _viewDistanceRange.Lerp(sizeToDistanceAlpha); transform.position = Vector3.Lerp(transform.position, _targetPosition, Time.deltaTime * _zoomLerpSpeed); }
void Update() { if (_currentBall) { if (_debugCanShoot) { if (_inputDevice.Action3.WasPressed) { _isShooting = true; _shootTimer = 0f; } if (_isShooting && _inputDevice.Action3.WasReleased) { // TODO: Clamp these to character specific angles ShootBall(_inputDevice.LeftStick.Vector, _shotForceRange.Lerp(_shootTimer / _maxShootTime)); _isShooting = false; } } } else if (_inputDevice.Action3.WasPressed && _stealCooldownTimer > _stealCooldownTime) { AttemptSteal(); } }
void FixedUpdate() { if (_currentBall) { if (_isShooting && _inputDevice.Action3.IsPressed) { _shootTimer += Time.deltaTime; } if (player.physics.isGrounded) { _currentBallHeightOffset = Mathf.Sin(_dribbleTimer) * 0.5f + 0.5f; _currentBallHeightOffset = _ballHeightOffsetRange.Lerp(_currentBallHeightOffset); _dribbleTimer += Time.deltaTime * _dribbleSpeed; } _currentBall.transform.position = Vector3.Lerp(_currentBall.transform.position, transform.position + Vector3.up * _currentBallHeightOffset, Time.deltaTime * _ballFollowSpeed); } _stealCooldownTimer += Time.deltaTime; _catchCooldownTimer += Time.deltaTime; }