mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 03:53:04 +00:00
increase node search radius for escaping
This commit is contained in:
parent
8318a3c9b1
commit
e823af2e22
2 changed files with 6 additions and 6 deletions
|
@ -7,6 +7,8 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
private readonly PathMovementData _pathMovementData = new PathMovementData();
|
||||
public PathMovementData PathMovementData => _pathMovementData;
|
||||
|
||||
public float nodeSearchRadius = 500f;
|
||||
|
||||
|
||||
public override void OnBecameInactive()
|
||||
{
|
||||
|
@ -31,7 +33,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
|
||||
if (!_pathMovementData.destinationNode.HasValue)
|
||||
{
|
||||
PedAI.FindClosestWalkableNode(_pathMovementData, _ped.transform.position);
|
||||
PedAI.FindClosestWalkableNode(_pathMovementData, _ped.transform.position, this.nodeSearchRadius);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,14 +134,14 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
return targetNode.Position + offset.ToVector3XZ();
|
||||
}
|
||||
|
||||
public static void FindClosestWalkableNode(PathMovementData pathMovementData, Vector3 position)
|
||||
public static void FindClosestWalkableNode(PathMovementData pathMovementData, Vector3 position, float radius = 200f)
|
||||
{
|
||||
if (Time.timeAsDouble - pathMovementData.timeWhenAttemptedToFindClosestNode < 2f) // don't attempt to find it every frame
|
||||
return;
|
||||
|
||||
pathMovementData.timeWhenAttemptedToFindClosestNode = Time.timeAsDouble;
|
||||
|
||||
var closestPathNodeToWalk = PedAI.GetClosestPathNodeToWalk(position);
|
||||
var closestPathNodeToWalk = PedAI.GetClosestPathNodeToWalk(position, radius);
|
||||
if (null == closestPathNodeToWalk)
|
||||
return;
|
||||
|
||||
|
@ -225,10 +225,8 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
return previousNode;
|
||||
}
|
||||
|
||||
public static PathNode? GetClosestPathNodeToWalk(Vector3 pos)
|
||||
public static PathNode? GetClosestPathNodeToWalk(Vector3 pos, float radius)
|
||||
{
|
||||
float radius = 200f;
|
||||
|
||||
var pathNodeInfo = NodeReader.GetAreasInRadius(pos, radius)
|
||||
.SelectMany(area => area.PedNodes)
|
||||
.Where(node => !node.Flags.EmergencyOnly)
|
||||
|
|
Loading…
Reference in a new issue