Astar Change node collision
I'm looking to change the nodes (2) within the area indicated by the box or red outline from being an obstacle, to not an obstacle, but cannot figure out how.
I'm using Unity's Tilemap feature. This in conjunction with astar pathfinding (Aran Granberg). The red squares that you see indicate that the tile is an obstacle. The blue ones indicate it is not an obstacle. I want to change the tiles within the area indicated by the white bounding box to be not an obstacle, during runtime. I will use whatever works. Be it this bounding box ( generated using the GraphUpdateSene component), a collider of some kind, or anything else that might work. I need a way to detect which tiles are within an area, and then do something with said tiles.
Here's some code examples that I've tried. None of them work.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
using Pathfinding;
public class LevBridge : MonoBehaviour {
public Tilemap tileMap;
private List<Tile> tiles = new List<Tile>();
public BoundsInt area;
private Vector3Int tPos;
TileBase tileBase;
TileData tileData;
private void Start()
{
tileMap = GameObject.Find("Pit").GetComponent<Tilemap>();
tPos = tileMap.WorldToCell(transform.position);
tileBase = tileMap.GetTile(tPos);
//tileMap.SetTile(tPos, null);
//tileMap.SetColliderType(tPos, Tile.ColliderType.None);
tileMap.GetComponent<TilemapCollider2D>().enabled = false;
tileMap.RefreshTile(tPos);
AstarPath.active.Scan();
//TileBase[] tileArray = tileMap.GetTilesBlock(area);
//foreach (Tile tile in tileArray)
//{
// print("hello");
// tile.colliderType = 0;
// Destroy(tile);
//}
}
Your answer
Follow this Question
Related Questions
Compatible collision constraint methods 0 Answers
Sound on collision. 1 Answer
Stop objects from going through eachother? 0 Answers
Raycast not detecting hit 4 Answers
how should i put the colliders? 1 Answer