]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix ghosts following a moving entity causing them to be offset (#22783)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Wed, 20 Dec 2023 23:33:00 +0000 (00:33 +0100)
committerGitHub <noreply@github.com>
Wed, 20 Dec 2023 23:33:00 +0000 (15:33 -0800)
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.

Content.Shared/Follower/FollowerSystem.cs

index 58a94d1723a2c7bf65d54b7bc1c18d4560922109..41ee215fe253075b223e863de1721ac2c7e508e4 100644 (file)
@@ -162,8 +162,6 @@ public sealed class FollowerSystem : EntitySystem
         if (TryComp<JointComponent>(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<OrbitVisualsComponent>(follower);
 
         var followerEv = new StartedFollowingEntityEvent(entity, follower);