A* Pathfinding Project

Draw a path with seeker tag penalties


#1

Hi,

How would I be able to draw a path using seeker tag penalties? I have tried this:

        CombatPath = ABPath.Construct (transform.position, hit [0].point, DrawPath);

and then DrawPath has a loop like this:

      for (int i = 1; i < path.vectorPath.Count; i++) {
        GameObject pathPoint = Instantiate (MovePointPrefab, path.vectorPath [i], Quaternion.identity);
        SpriteRenderer spriteRenderer = pathPoint.GetComponent<SpriteRenderer> ();
        Color color = Color.green;

        if (i > characterMovement.MovementPoints) {
          color = Color.red;
        }

        spriteRenderer.color = color;
        movePointPrefabs.Add (pathPoint);
      }

But it’s just a basic path and doesn’t care about tag penalties. If I use seeker.StartPath (CombatPath, DrawPath); the AIPath starts moving down the path instantly. I don’t want the AI to use this path.

Using GraphUpdateScene Penalty Delta values works with this, but I’d rather use tags.


#2

Hi

To use the Seeker’s settings when searching for a path (without using the Seeker itself) you can do this:

var path = ABPath.Construct (transform.position, hit [0].point, DrawPath);
path.nnConstraint.graphMask = seeker.graphMask;
path.tagPenalties = seeker.tagPenalties;
path.enabledTags = seeker.traversableTags;
AstarPath.StartPath(path);