#Is there anyway I could improve my pathfinding algorithm?

1 messages · Page 1 of 1 (latest)

robust peak
#

Attached is my pathfinding code

[HideInInspector] public float NPC_PathfindMoveCounter;
[HideInInspector] public Vector3 NPC_PathfindDir;
[HideInInspector] Vector3 NPC_PathfindDirCheck;
static Vector3 pathfindingFloorBoxSize = new Vector3(0.2f, 1.5f, 0.2f);
static Vector3 pathfindingWallBoxSize = new Vector3(0.2f, 1.0f, 0.2f);
static float pathfindingDistWall = 0.5f;
static LayerMask pathfindingLayermask = ~0;```

Here is all the other variables. Not included is code to move towards it, which is a simple ``CharacterController.move`` call. Anyway I could improve my pathfinding algorithm? I KNOW I should probably use the navmesh but I would rather not use that
warm sparrow
#

Is there any specific reason you don't want to use the navmesh?

worthy forum
#

The question is a bit vague. What are your goals, and what problems are you encountering?

#

I'm asking this, because the way you currently do it results in a rather specific behaviour and is not the "perfect" way to get anywhere, which is maybe desired?

If your goal is really just to find the shortest path, then yeah, either a navmesh or grid-based solution seems better