Fix physics pushing rotation bugs (#4288)

This commit is contained in:
metalgearsloth
2021-07-19 18:49:18 +10:00
committed by GitHub
parent bf493c39b7
commit 5e2cdcfd37

View File

@@ -24,17 +24,15 @@ namespace Content.Shared.Movement.EntitySystems
/// <summary> /// <summary>
/// Fake pushing for player collisions. /// Fake pushing for player collisions.
/// </summary> /// </summary>
private void HandleCollisionMessage(Fixture ourFixture, Fixture otherFixture, float frameTime, Manifold manifold) private void HandleCollisionMessage(Fixture ourFixture, Fixture otherFixture, float frameTime, Vector2 worldNormal)
{ {
var otherBody = otherFixture.Body; var otherBody = otherFixture.Body;
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return; if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
var normal = manifold.LocalNormal; if (!ourFixture.Body.Owner.TryGetComponent(out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return;
if (!ourFixture.Body.Owner.TryGetComponent(out IMobMoverComponent? mobMover) || normal == Vector2.Zero) return; otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime);
otherBody.ApplyLinearImpulse(-normal * mobMover.PushStrength * frameTime);
} }
} }
} }