Fixes recoil and adjusts values (#1573)

This commit is contained in:
Qustinnus
2020-08-09 20:56:02 +02:00
committed by GitHub
parent d4f406337e
commit 81e2dde7f5
2 changed files with 5 additions and 4 deletions

View File

@@ -15,16 +15,16 @@ namespace Content.Client.GameObjects.Components.Mobs
public sealed class CameraRecoilComponent : SharedCameraRecoilComponent public sealed class CameraRecoilComponent : SharedCameraRecoilComponent
{ {
// Maximum rate of magnitude restore towards 0 kick. // Maximum rate of magnitude restore towards 0 kick.
private const float RestoreRateMax = 2f; private const float RestoreRateMax = 15f;
// Minimum rate of magnitude restore towards 0 kick. // Minimum rate of magnitude restore towards 0 kick.
private const float RestoreRateMin = 1f; private const float RestoreRateMin = 1f;
// Time in seconds since the last kick that lerps RestoreRateMin and RestoreRateMax // Time in seconds since the last kick that lerps RestoreRateMin and RestoreRateMax
private const float RestoreRateRamp = 0.05f; private const float RestoreRateRamp = 0.1f;
// The maximum magnitude of the kick applied to the camera at any point. // The maximum magnitude of the kick applied to the camera at any point.
private const float KickMagnitudeMax = 0.25f; private const float KickMagnitudeMax = 5f;
private Vector2 _currentKick; private Vector2 _currentKick;
private float _lastKickTime; private float _lastKickTime;
@@ -87,6 +87,7 @@ namespace Content.Client.GameObjects.Components.Mobs
// Continually restore camera to 0. // Continually restore camera to 0.
var normalized = _currentKick.Normalized; var normalized = _currentKick.Normalized;
_lastKickTime += frameTime;
var restoreRate = FloatMath.Lerp(RestoreRateMin, RestoreRateMax, Math.Min(1, _lastKickTime/RestoreRateRamp)); var restoreRate = FloatMath.Lerp(RestoreRateMin, RestoreRateMax, Math.Min(1, _lastKickTime/RestoreRateRamp));
var restore = normalized * restoreRate * frameTime; var restore = normalized * restoreRate * frameTime;
var (x, y) = _currentKick - restore; var (x, y) = _currentKick - restore;

View File

@@ -143,7 +143,7 @@ namespace Content.Server.Explosions
delta = _epicenterDistance; delta = _epicenterDistance;
var distance = delta.LengthSquared; var distance = delta.LengthSquared;
var effect = 1 / (1 + 0.2f * distance); var effect = 10 * (1 / (1 + distance));
if (effect > 0.01f) if (effect > 0.01f)
{ {
var kick = -delta.Normalized * effect; var kick = -delta.Normalized * effect;