public bool Intersect(PathfollowingController i_pathfollowingController) { float xMin = transform.position.x - sprite_renderer.bounds.extents.x; float xMax = transform.position.x + sprite_renderer.bounds.extents.x; float yMin = transform.position.y - sprite_renderer.bounds.extents.y; float yMax = transform.position.y + sprite_renderer.bounds.extents.y; Vector2 position = i_pathfollowingController.transform.position; return (position.x > xMin && position.x < xMax && position.y > yMin && position.y < yMax); }
private void Start() { // Create and center the grid grid.Create(numRow, numColumn); Vector2 gridSize = grid.size; Vector2 gridPos = new Vector2(gridSize.x * -0.5f, gridSize.y * 0.5f); grid.transform.position = gridPos; m_controller = Instantiate<PathfollowingController>(pathfollowingController); m_inputManager = GameObject.FindGameObjectWithTag("InputManager").GetComponent<InputManager>(); BuildBehaviourTree(); }