[Unity] a* pathfinding project - Graph Center 변경

Flaming Bun·2025년 7월 1일

Unity

목록 보기
26/39

🔥 Graph의 Center 변경

a* pathfinding project의 Graph를 이동하려면 center 속성을 이용해서 이동시켜야 한다.

⚔ 코드

   public AstarPath astarPath;

   public void LocateAStarGraph(Vector3 centerPosition)
    {
        var grid = astarPath.data.gridGraph;
        if (grid != null)
        {
            grid.center = centerPosition;
            // 이동 후 그래프 다시 스캔
            AstarPath.active.Scan();
        }
    }

0개의 댓글