From 3cf08af9ddeba876b99e615514d62b6dc9c56d83 Mon Sep 17 00:00:00 2001 From: Michael Cooke Date: Sat, 31 Jul 2021 08:53:18 -0400 Subject: [PATCH] Fix opposite force when throwing objects (#4398) * Fix opposite force when throwing objects * DRY the throw impulse vector calculation --- Content.Server/Throwing/ThrowHelper.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index 7230c6b534..ae4ec3d96d 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -69,7 +69,9 @@ namespace Content.Server.Throwing EntitySystem.Get().ThrownInteraction(user, entity); } - physicsComponent.ApplyLinearImpulse(direction.Normalized * strength * physicsComponent.Mass); + var impulseVector = direction.Normalized * strength * physicsComponent.Mass; + physicsComponent.ApplyLinearImpulse(impulseVector); + // Estimate time to arrival so we can apply OnGround status and slow it much faster. var time = (direction / strength).Length; @@ -96,7 +98,7 @@ namespace Content.Server.Throwing if (!msg.Cancelled) { - body.ApplyLinearImpulse(-direction * pushbackRatio); + body.ApplyLinearImpulse(-impulseVector * pushbackRatio); } } }