More NPC steering fixes (#17042)
This commit is contained in:
@@ -348,6 +348,17 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
|
||||
}
|
||||
DebugTools.Assert(!float.IsNaN(interest[0]));
|
||||
|
||||
// Don't steer too frequently to avoid twitchiness.
|
||||
// This should also implicitly solve tie situations.
|
||||
// I think doing this after all the ops above is best?
|
||||
// Originally I had it way above but sometimes mobs would overshoot their tile targets.
|
||||
|
||||
if (!forceSteer && steering.NextSteer > curTime)
|
||||
{
|
||||
SetDirection(mover, steering, steering.LastSteerDirection, false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid static objects like walls
|
||||
CollisionAvoidance(uid, offsetRot, worldPos, agentRadius, layer, mask, xform, danger, dangerPoints, bodyQuery, xformQuery);
|
||||
DebugTools.Assert(!float.IsNaN(danger[0]));
|
||||
@@ -376,17 +387,6 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem
|
||||
resultDirection = new Angle(desiredDirection * InterestRadians).ToVec();
|
||||
}
|
||||
|
||||
// Don't steer too frequently to avoid twitchiness.
|
||||
// This should also implicitly solve tie situations.
|
||||
// I think doing this after all the ops above is best?
|
||||
// Originally I had it way above but sometimes mobs would overshoot their tile targets.
|
||||
|
||||
if (!forceSteer && steering.NextSteer > curTime)
|
||||
{
|
||||
SetDirection(mover, steering, steering.LastSteerDirection, false);
|
||||
return;
|
||||
}
|
||||
|
||||
steering.NextSteer = curTime + TimeSpan.FromSeconds(1f / NPCSteeringComponent.SteeringFrequency);
|
||||
steering.LastSteerDirection = resultDirection;
|
||||
DebugTools.Assert(!float.IsNaN(resultDirection.X));
|
||||
|
||||
Reference in New Issue
Block a user