-
-
Couldn't load subscription status.
- Fork 101
Description
Describe the project you are working on
3D Battle
Describe the problem or limitation you are having in your project
Some NodePaths are simply the property name:
CreateTween().TweenProperty(Camera, "position", endPos, delay);So I thought I could use PropertyName:
CreateTween().TweenProperty(Camera, Node3D.PropertyName.Position, endPos, delay);I could cast it to string and then the implicitly conversion of string -> NodePath.
CreateTween().TweenProperty(Camera, Node3D.PropertyName.Position.ToString(), endPos, delay);But I think you should be able to convert from StringName to NodePath without ever using a string:
CreateTween().TweenProperty(Camera, (NodePath)Node3D.PropertyName.Position, endPos, delay);Describe the feature / enhancement and how it helps to overcome the problem or limitation
Looking at source code of StringName and NodePath I notice they are oddly equal.
I even ask myself if there any point in having both, other than just matching GDScript?
Can't StringName and NodePath have a common ancestor? I think that is possible since both are not auto-generated. And the only fields difference between then are godot_string_name and godot_node_path, but both are the exact same thing.
With that question aside I think there some solutions (In the order I like the most):
-
Makes somehow possible to cast StringName to NodePath. (If they have a common ancestor this would be trivial)
-
Make all functions that accept NodePath also accept StringName
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
CreateTween().TweenProperty(Camera, (NodePath)Node3D.PropertyName.Position, endPos, delay);CreateTween().TweenProperty(Camera, Node3D.PropertyName.Position, endPos, delay);If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be work around by simple doing a string cast, but that will call: https://github.com/godotengine/godot/blob/fa3428ff25bc577d2a3433090478a6d615567056/modules/mono/glue/GodotSharp/GodotSharp/Core/StringName.cs#L90C32-L90C40
and then:
https://github.com/godotengine/godot/blob/fa3428ff25bc577d2a3433090478a6d615567056/modules/mono/glue/GodotSharp/GodotSharp/Core/NodePath.cs#L119
Which is not ideal
Is there a reason why this should be core and not an add-on in the asset library?
StringName and NodePath are built-in classes