Hello everyone, im working with Godot roughly for more then a year already (time flys..), but in most cases i still feel
like im having no idea what im doing when it comes to scripts XD.. However, is there a way to add or remove a script of a node via script of its parent or main_scene? That could be a way for making nodes "sleep" or pause, wich would be very helpful for my project. Right now im thinking of something like: Parent(script)says: if Input.is_action_just_pressed(key): -> $Tank.script (var script= preload(any gd).
(some minutes later): Well i tried now, but it seems that its not connecting any signals from the node to the sript that i've added.
I don't even know if "set_script" is really adding a script.. even if the "var" is telling what to do.
Add or remove a script through script of parent or main_scene (?)
Gaming911 That could be a way for making nodes "sleep" or pause, wich would be very helpful for my project.
Would setting a state-like flag to process (or not) be better here? Or even node->set_process(false)
(rtfm) (or other functions). A quick example could be as simple as:
var active = false:
get:
return active
set(value):
set_process(value)
active = value
Generally, yes - set_script
(doc) would be okay. Perhaps show how you're connecting signals and the tank script itself if you want to persist manually spawning scripts?
spaceyjase First: nice, thanks for the fast reply. Well im connecting the signals to the script with the Signals line on the right from the editor Node-Window. I solved the problem now on an other way: My tank needs for movement, targeting etc a value to interact.
Like: if target == 1: -> fire_cannon = true and so on. So if im playing with these "var" values i can control if the node is active or not.
With setting all CollisionShapes to disabled and the node itself.visible = false. And all needed var that has to be "1" to "0"