0 votes

Hey all,

I've created a subclass of AStar2D and tried to override the computecost() and estimatecost() functions. I'm trying to make it so A* sees the distance between any two connected nodes as 1. That way, the shortest path is determined only by the number of connections.

Here's my code: https://pastebin.com/dyVnagqX

It seems to be ignoring the functions I've written. Firstly, it fails to calculate the shortest path, and secondly, it doesn't print "blamo" to the console when computing distance.

Anybody know what I'm doing wrong?


in Engine by (16 points)

2 Answers

+1 vote

What version of Godot are you using? Poking around, it seems that AStar2D didn't used to allow those methods to be overridden (even though AStar did). However, reading this...




...makes me think the necessary changes were implemented in AStar2D and were cherry-picked into both 3.2.3 and 3.2.2.

by (12,286 points)

Ah, perfect. Upgrading fixed the problem. I was running 3.2.1 I think. Thanks for looking into this for me!

0 votes

Upgrading fixed the problem. I was running 3.2.1.

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.