-
Is it possible to make fields in class structure which will be like gdscript
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Any exported fields in the Go struct will be exported to Godot (just like @export) type MyClass struct {
gd.Class[MyClass, Node]
Camera gd.Camera3D `gd:"camera"`
} If you add an exported node field to a node, it will be asserted as a child, so in the above example, the Camera will be added as a child node of MyClass. |
Beta Was this translation helpful? Give feedback.
-
type Player struct {
gd.Class[Player, gd.CharacterBody3D]
CameraMount struct {
gd.Node3D
Camera gd.Camera3D
}
} Thank you for provided suggestion! I see what it creates 3 separated nodes under Player node: "CameraMount" (node3d), "Node3D" (node3d) and "Camera" (camera3d). For now it looks a bit like a bug or it is correct behavior? Also Camera is not a child of CameraMount. And I just cant understand what creating that "Node3D" node. If it is CameraMount struct representation then why "CameraMount" even was created If it is correct behavior - I a bit misunderstand logic here, maybe you will be able to explain? |
Beta Was this translation helpful? Give feedback.
Any exported fields in the Go struct will be exported to Godot (just like @export)
https://go.dev/ref/spec#Exported_identifiers
If you add an exported node field to a node, it will be asserted as a child, so in the above example, the Camera will be added as a child node of MyClass.