Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AStar Point should have the possibility to have weight of 0 #4477

Closed
LordBrkica opened this issue May 1, 2022 · 2 comments · Fixed by godotengine/godot#60811
Closed

AStar Point should have the possibility to have weight of 0 #4477

LordBrkica opened this issue May 1, 2022 · 2 comments · Fixed by godotengine/godot#60811
Milestone

Comments

@LordBrkica
Copy link

LordBrkica commented May 1, 2022

Describe the project you are working on

Turn based strategy game (like Civilization 3).

Describe the problem or limitation you are having in your project

The minimal value of a point in AStar2D class is 1. This is stated in the docs under add_point():

This is a problem because I would like some points to have a value of 0.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Civlization 3 has this grid of tiles. Each tile has a movement cost, mountains increase the cost, roads decrease the cost...
Rails reduce the cost to 0 (so one can move a unit across the continent in one turn).

I would like to have the option to set the movement cost of AStar2D Point to 0.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The limit of 1 should be reduced to 0.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Everything can be workaround, but I dont see why we have such a limit. There is no mathematical problem if some point has a weight cost of 0.

Is there a reason why this should be core and not an add-on in the asset library?

There is no reason to limit this functionality.

ADDITIONAL - it should not be possible to use 0 as is !
Right now using 0 like this:
astar2dObject.SetPointWeightScale(index, 0);

gets SILENTLY converted to 1 which is horrible practice. It would be better if the function simply fails/throws an exception when 0 is recieved.
One should NOT simply arbitrarly feed a function values the programmer did NOT use !

I mean this could even be considered a bug.
Image calling some function:
addition(-1, 3)
where -1 gets silently set to 1 (because minus numbers are not supported). So insted of result being 2, you get 4. as result

@timothyqiu
Copy link
Member

Right now using 0 like this: astar2dObject.SetPointWeightScale(index, 0);

gets SILENTLY converted to 1 which is horrible practice. It would be better if the function simply fails/throws an exception when 0 is recieved. One should NOT simply arbitrarly feed a function values the programmer did NOT use !

The current 3.4.4.stable reports an error for this:

E 0:00:00.271 set_point_weight_scale: Can't set point's weight scale less than one: 0.000000.

And it's not converting 0 to 1, the function fails and the original value 1 is not changed.

@LordBrkica
Copy link
Author

LordBrkica commented May 2, 2022

I am working on C#/Mono and using 3.5.4.beta.

You are right, its silent fail with errors in log.
But the errors dont break my game (and I use no try catch) so one can believe everythig is ok.

In any way - I think 0 should be a valid value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants