From: Pieter-Jan Briers Date: Wed, 20 Dec 2023 23:33:00 +0000 (+0100) Subject: Fix ghosts following a moving entity causing them to be offset (#22783) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=5e6f350731d81b287c54bb256b68474580836124;p=space-station-14.git Fix ghosts following a moving entity causing them to be offset (#22783) Fixes #14220 Because the entity they start following is moving, the physics system gives the follower opposing velocity to counteract, at the time the parent change happens. This happens *after* the follower system tries to clear the follower's velocity, so the follower gets some velocity that will still move them a bit off-center. Fix is easy enough, just reset velocity *after* reparenting, not before. --- diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 58a94d1723..41ee215fe2 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -162,8 +162,6 @@ public sealed class FollowerSystem : EntitySystem if (TryComp(follower, out var joints)) _jointSystem.ClearJoints(follower, joints); - _physicsSystem.SetLinearVelocity(follower, Vector2.Zero); - var xform = Transform(follower); _containerSystem.AttachParentToContainerOrGrid((follower, xform)); @@ -173,6 +171,8 @@ public sealed class FollowerSystem : EntitySystem _transform.SetCoordinates(follower, xform, new EntityCoordinates(entity, Vector2.Zero), rotation: Angle.Zero); } + _physicsSystem.SetLinearVelocity(follower, Vector2.Zero); + EnsureComp(follower); var followerEv = new StartedFollowingEntityEvent(entity, follower);