Support Forum

TD - Prevent a path from being blocked - ispathpossible / updategraphsnoblock setup help

Hi, I am new to this and am struggling to get ​ispathpossible and updategraphsnoblock to work in my scripts. I have the pro version.

this is my build script -


using UnityEngine;
using Pathfinding;

public class TowerNode : MonoBehaviour
{
    private GameObject tower;

    private void OnMouseDown() {

        if (tower != null) {

            Debug.Log("Can't build here!");
            return;
        }
        
        GameObject towerToBiuld = BuildingManager.instance.GetTowerToBuild();
        tower = (GameObject)Instantiate(towerToBiuld, transform.position, transform.rotation);

        AstarPath.active.Scan();
    }


How do i get either of the two to work when instantiating a tower? are they used like an if statement? e.g


if (isPathPossible = true) {

GameObject towerToBiuld = BuildingManager.instance.GetTowerToBuild();
        tower = (GameObject)Instantiate(towerToBiuld, transform.position, transform.rotation);

        AstarPath.active.Scan();

} else {

Debug.Log ("Cant block the path");

}

a poor example I know.

Thanks for the help

A

Any one got any ideas on this. Appreciate the help