-
-
Couldn't load subscription status.
- Fork 101
Description
Describe the project you are working on
A game with a lot of dynamic code.
Describe the problem or limitation you are having in your project
Currently, if you have a NodePath like ^"A/B/C/D/E/F", there is no easy way to get only the first X names in the path, such as if you only wanted the first 4 names ^"A/B/C/D".
The only way to get this would be to manually reconstruct it in GDScript. However, this would be extremely inefficient compared to what's optimal, since the NodePath constructor that accepts an array of StringNames is not exposed, it's only internal to the engine, so you would have to build a String which then gets split up again. Horrible!
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add a method that allows getting a partial path from a NodePath.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
See this PR: godotengine/godot#78638
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around but not in a few lines and extremely inefficiently.
I don't know how often this will be used. I suspect that this will not be used often, but I have no idea.
Is there a reason why this should be core and not an add-on in the asset library?
Yes, because this is heavily related to NodePath and NodePath is a part of core. The ability to manipulate NodePaths to get other NodePaths seems like a very core feature that NodePath should have.