Hello all, I’m making a 2d top down game. The player can spawn lines that auto destroy themselves after a couple of seconds, they are obstacles for the enemy that follows the player. When I spawn an obstacle it works fine and the enemy recalculates the path correctly, but when the line is destroyed the nodes that were unwalkable because of the line are still unwalkable except the nodes on the middle of the line that are walkable again, even if I made an update of the graph just before the line dies. The line has 2 colliders 1 is for the player and the enemies the other is in a child object of the line and is in another layer (the layer is “nodes”) the grid checks the collisions only in the nodes layer. Here’s the code:
// Update is called once per frame
void Update()
{
//if time's off destroy the line
if (time_duration_line <= 0 && !Input.GetKeyDown(KeyCode.Space))
{
...
//update the graph
//get the child's collider (that's the collider that handles
//the collisions with the nodes
Collider2D child_node_colz = gameObject.GetComponentInChildren<BoxCollider2D>();
//disable the collider that so the bounds will be "empty"
child_node_colz.enabled = false;
AstarPath.active.UpdateGraphs(child_node_colz.bounds);
Destroy(gameObject);
}
}
What should I change?
Thank you in advance guys 