// Called when the node enters the scene tree for the first time. public override void _Ready() { RequestPathEvent.RegisterListener(GetPath); nav2D = GetNode <Navigation2D>("../Nav2D"); //Get the ti;e map and the naviation map here }
private void AIGetPath() //private void GetPath(SendPathEvent spei) { RequestPathEvent rpei = new RequestPathEvent(); rpei.requester = (Node2D)GetParent(); rpei.target = target; rpei.FireEvent(); path = rpei.path; }
public override void _ExitTree() { RequestPathEvent.UnregisterListener(GetPath); }
private void GetPath(RequestPathEvent rpei) { //Get the generated path Vector2[] path = nav2D.GetSimplePath(rpei.requester.GlobalPosition, rpei.target.GlobalPosition); rpei.path = path; }