コード例 #1
0
        protected override void updateTransform(float positionAvg, float rotationAvg)
        {
            if (_cameraTransform == null || followObject == null)
            {
                return;
            }

            lookAtPosition = getLookatPosition();
            newPosition    = getPosition();

            if (_shakeOffset != Vector3.zero)
            {
                this._cameraTransform.position = newPosition + _shakeOffset;
            }
            else
            {
                newPosition = Vector3.Lerp(this._cameraTransform.position, newPosition, positionAvg);
                rotation    = Quaternion.LookRotation(lookAtPosition, Vector3.up);

                this._cameraTransform.position = newPosition;
                this._cameraTransform.rotation = Quaternion.Lerp(this._cameraTransform.rotation, rotation, rotationAvg);
            }

            TickManager.LateCameraUpdate();
        }
コード例 #2
0
        protected virtual void LateUpdate()
        {
            if (this._cameraTransform == null)
            {
                return;
            }

            if (!this.followObject || this.isCameraFocusing)
            {
                TickManager.LateCameraUpdate();
                return;
            }

            if (this._isNeedResetDistance)
            {
                float deltaSlepTime = Time.time - this._startResetSlepTime;
                if (deltaSlepTime > this.resetTime)
                {
                    deltaSlepTime             = this.resetTime;
                    this._isNeedResetDistance = false;
                }

                this.distance = Mathf.Lerp(this.distance, this.toDistance, deltaSlepTime / this.resetTime);
            }


            float t = Time.fixedDeltaTime;

            this.updateTransform(positionAvgSpeed * t, rotationAvgSpeed * t);
        }