Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | indicainkwell | |
Old Version | Published before Godot 3 was released. |
In Unity you would create scripts that could be small and specific and then attach any number of them to a game object to build functionality. For a very simple example: you have 3 scripts that rotate the game object on one of the x, y, or z axes. In the scene you have 4 game objects; 1 rotate on all axes, 1 to rotate on xy axis, 1 to rotate on x axis, and 1 to rotate on yz axis.
You add the scripts with the intended functionality as components to the game object.
In godot it appears you have to write a new script for each functionality or add some more code to an existing script on a node. Which seems like it can really bloat a script on a specific node.
I was thinking of creating an empty Node and adding sub nodes with scripts. Kind of acting like a folder. Then instance that Node under some other node that I want to get the functionality of that “folder” of scripts by exporting a NodePath var in the parent Node and pass it to the functional sub nodes.
I haven’t done that because it seems like an anti pattern and you can’t directly handle stuff like input and drawing you’d have to create a mediator object of some sort.
Also, how’s subclassing from another gdscript? I’ve read somewhere from experienced godot users that they don’t use the extends "some-script.gd"
Why is that? Other than you don’t get autocompletions in the script editor.