// Update is called once per frame void Update() { if (_rb.velocity.magnitude > _velocityLimits.min) { float velocityN = Mathf.Clamp(_velocityLimits.InverseLerp(_rb.velocity.magnitude), 0, 1); float emission = _emissionRange.Lerp(velocityN); _particleSystem.Emit((int)emission); } }
// ---- Position ---- void updatePosition() { // set zoom amount, smoothed // get the normalized distance between the zoom limits, then ease it. _targetDistN = _distanceLimits.InverseLerp(Vector3.Distance(_targetPos, transform.position)); if (_zoomSpeedEasing.keys.Length > 0) { _targetDistN = _zoomSpeedEasing.Evaluate(_targetDistN); } _desiredDistance += _inputState.zoom * Time.deltaTime * _zoomSpeed.Lerp(_targetDistN); _desiredDistance = _distanceLimits.ClampValue(_desiredDistance); _currDistance = Mathf.Lerp(_currDistance, _desiredDistance, Time.deltaTime * _zoomDampening); // calculate position based on the new distance transform.position = _targetPos - (transform.forward * _currDistance) + _targetOffset; }