public Vector2[] CalcPath(Vector2 start, Vector2 end) { var curPath = pathmaker.GetSimplePath(start, end, true); var testPath = pathmaker.GetSimplePath(start, pathmaker.GetClosestPoint(end), true); if (end != pathmaker.GetClosestPoint(end)) { end.x = end.x + 0.01f; } bool optiChoice = true; return(pathmaker.GetSimplePath(start, end, optiChoice)); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print("doing ready on " + this.Name); floor = GetNode("Navigation2D/TileMap") as TileMap; pathmaker = GetNode("Navigation2D") as Navigation2D; Vector2 startPoint = pathmaker.GetClosestPoint(new Vector2(25, 25)); Vector2 endPoint = pathmaker.GetClosestPoint(new Vector2(350, 25)); //var difDemoPath = pathmaker.GetSimplePath(startPoint,endPoint, true) as Godot.Collections.Array<Vector2>; Vector2[] demoPath = pathmaker.GetSimplePath(startPoint, endPoint, true); GD.Print(demoPath.ToString()); foreach (var point in demoPath) { GD.Print("raw points: " + point); GD.Print("tilepoints: " + floor.WorldToMap(point)); } base._Ready(); }