public override void _Process(float delta) { var player = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP); if (player != null) { _targetPosition = player.GetCameraTargetPosition() + _shift; } GlobalPosition = GlobalPosition.LinearInterpolate(_targetPosition, CAMERA_FOLLOW * delta); if (_amplitude > 0f) { _xNoiseSample += X_NOISE_GROWTH * delta; _yNoiseSample += Y_NOISE_GROWTH * delta; _xNoiseSample = Mathf.Wrap(_xNoiseSample, 0f, NOISE_MAX); _yNoiseSample = Mathf.Wrap(_yNoiseSample, 0f, NOISE_MAX); _offset.x = PerlinNoise.Noise(_xNoiseSample); _offset.y = PerlinNoise.Noise(_yNoiseSample); _amplitude = Mathf.Clamp(_amplitude - AMPLITUDE_DECAY * delta, 0f, 5f); _offset *= MAX_OFFSET * _amplitude * _amplitude; Offset = _originalOffset + _offset; } }
public override void _Process(float delta) { var player = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP); if (player != null) { var mouseVec = GetGlobalMousePosition() - player.GlobalPosition; _targetPos = player.GlobalPosition + mouseVec * AIM_OFFSET; } else { _targetPos = GetGlobalMousePosition(); } GlobalPosition = GlobalPosition.LinearInterpolate(_targetPos, 10 * delta / Engine.TimeScale); UpdateShake(); }