Fix opposite force when throwing objects (#4398)

* Fix opposite force when throwing objects

* DRY the throw impulse vector calculation
This commit is contained in:
Michael Cooke
2021-07-31 08:53:18 -04:00
committed by GitHub
parent c0c18b555b
commit 3cf08af9dd

View File

@@ -69,7 +69,9 @@ namespace Content.Server.Throwing
EntitySystem.Get<InteractionSystem>().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);
}
}
}