CameraZoom.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        if (isZooming) {
            zoom = Mathf.Lerp(zoom,zoomTo,Time.deltaTime*zoomSpeed);
            if (Mathf.Abs(zoomTo-zoom) < 0.05) {
                zoom = zoomTo;
                isZooming = false;
            }
            this.camera.orthographicSize = zoom;
        }
    }

Usage Example

Ejemplo n.º 1
0
    private void LateUpdate()
    {
        _cameraRotator.Update();
        _cameraZoom.Update(_lockOnTarget);
        if (_lockOnTarget != null)
        {
            _playerTransform.forward = Vector3.Scale((_lockOnTarget.Transform.position - _playerTransform.position).normalized, new Vector3(1, 0, 1));
            if (transform.forward.y < 0)
            {
                _cameraTargeting.Update(_lockOnTarget);
            }
            else
            {
                _lockOnTarget = null;
            }
        }
        else
        {
            var distance = Vector3.Distance(transform.position, Origin);
            if (distance > 0.25f)
            {
                transform.position = Vector3.Lerp(transform.position, Origin, Time.deltaTime * _smoothing / distance);
            }
            else
            {
                transform.position = Origin;
            }

            if (false)
            {
                var angle = Vector3.Angle(transform.forward, _playerTransform.forward);
                transform.forward = Vector3.Lerp(transform.forward, _playerTransform.forward, angle * Time.deltaTime);
                _faceForward      = false;
            }
        }
    }