More NPC steering tweaks (#14119)
This commit is contained in:
@@ -320,7 +320,7 @@ public sealed partial class NPCSteeringSystem
|
||||
EntityQuery<PhysicsComponent> bodyQuery,
|
||||
EntityQuery<TransformComponent> xformQuery)
|
||||
{
|
||||
var detectionRadius = MathF.Max(1.5f, agentRadius + moveSpeed / 4f);
|
||||
var detectionRadius = MathF.Max(1.5f, agentRadius);
|
||||
|
||||
foreach (var ent in _lookup.GetEntitiesInRange(uid, detectionRadius, LookupFlags.Static))
|
||||
{
|
||||
@@ -338,12 +338,24 @@ public sealed partial class NPCSteeringSystem
|
||||
if (!_physics.TryGetNearestPoints(uid, ent, out var pointA, out var pointB, xform, xformQuery.GetComponent(ent)))
|
||||
continue;
|
||||
|
||||
var obstacleDirection = pointB - worldPos;
|
||||
var obstacleDirection = pointB - pointA;
|
||||
var obstableDistance = obstacleDirection.Length;
|
||||
|
||||
if (obstableDistance > detectionRadius || obstableDistance == 0f)
|
||||
if (obstableDistance > detectionRadius)
|
||||
continue;
|
||||
|
||||
// Fallback to worldpos if we're colliding.
|
||||
if (obstableDistance == 0f)
|
||||
{
|
||||
obstacleDirection = pointB - worldPos;
|
||||
obstableDistance = obstacleDirection.Length;
|
||||
|
||||
if (obstableDistance == 0f)
|
||||
continue;
|
||||
|
||||
obstableDistance = agentRadius;
|
||||
}
|
||||
|
||||
dangerPoints.Add(pointB);
|
||||
obstacleDirection = offsetRot.RotateVec(obstacleDirection);
|
||||
var norm = obstacleDirection.Normalized;
|
||||
|
||||
Reference in New Issue
Block a user