Fixes movement and throwing incorrect tick-rate scaling (#1162)

* fixes movement and throwing scaling incorrectly w/ tick rate

* Update Content.Server/GameObjects/EntitySystems/MoverSystem.cs
This commit is contained in:
Tyler Young
2020-06-24 12:41:31 -04:00
committed by GitHub
parent 623e47f19d
commit b92a2ba4e6
2 changed files with 9 additions and 7 deletions

View File

@@ -83,7 +83,9 @@ namespace Content.Server.Throw
physComp = thrownEnt.AddComponent<PhysicsComponent>();
var timing = IoCManager.Resolve<IGameTiming>();
var spd = throwForce / (1f / timing.TickRate); // acceleration is applied in 1 tick instead of 1 second, scale appropriately
// scaling is handled elsewhere, this is just multiplying by 60 independent of timing as a fix until elsewhere values are updated
var spd = throwForce * 60;
physComp.SetController<ThrowController>();
(physComp.Controller as ThrowController)?.StartThrow(angle.ToVec() * spd);
@@ -146,10 +148,9 @@ namespace Content.Server.Throw
var velocityNecessary = distance / throwDuration;
var impulseNecessary = velocityNecessary * mass;
var forceNecessary = impulseNecessary * (1f / timing.TickRate);
// Then clamp it to the max force allowed and call Throw().
Throw(thrownEnt, MathF.Min(forceNecessary, throwForceMax), targetLoc, sourceLoc, spread, throwSourceEnt);
Throw(thrownEnt, MathF.Min(impulseNecessary, throwForceMax), targetLoc, sourceLoc, spread, throwSourceEnt);
}
}
}