#Is there a way to connect a signal from a scene dynamically created?
43 messages · Page 1 of 1 (latest)
can you get a reference to the ui from where you're creating the bullet?
good question 
I think I can do something like get_node("../ui")
would it be a good idea?
but is there a way to connect my bullets with the ui without doing it manually through the signals section? the bullets are only created during gameplay @meager linden
You can look at the "connect" call, it will connect signals programmatically:
var myBullet = <get a reference to the bullet>
myBullet.connect("signal", .......)
Look in the documentation, there is examples of this.
do you know if I can get the nodes name somehow?
im trying to print a function about the name, but it gives me @CharacterBody2D@22:<CharacterBody2D#39107692062> lmao
There are variaous ways, but without seeing how you create your bullets I don;t believe anyone can answer that.
That's it's name probably. If you are creating an instance , Godot will just give it a seemingly random name.
thats supposed to be the name of the thing it hit
for example this is one of the enemies, is there a way to get that Enemy1 label?
You'll have to get it when it's instanced.
Or maybe I'm not following you.
Also, very good info here in the "Connecting Signal via Code" section: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html#connecting-a-signal-via-code
In this lesson, we will look at signals. They are messages that nodes emit when something specific happens to them, like a button being pressed. Other nodes can connect to that signal and call a fu...
thanks
I got the signals stuff working just fine
now its printing what my bullet hit, which in this case is that Enemy1, but I also have other enemies
but idk if I can differentiate if I hit one or the other
its only giving me the reference which doesnt tell me much
your code likely will
it doesnt do things based off of the name you dont have to worry about that
right, but I would like to differentiate the enemies in order to get a different score
when I kill any of them
then you have two options i believe: just getting their name via enemy.Name or groups
do you know about the groups system
not really
was also trying to get the name, but it gives me some weird stuff
if I do node.name I get @CharacterBody2D@21
I was reading about unique names, but my character 2d doesnt have that option
its like tags in other software
you can go to the same panel where you connect signals, and click groups
you can add new groups to your nodes there
you can for example add a “StrongEnemy” group to a Strong Enemy and then use code to check the group and drop a certain amount of coins based on if it’s a strong enemy or not
thats interesting, im gonna do that then, seems to be a good solution 
i dont believe that’s what unique names are for, are you sure you’re printing node.Name?
yeah its less fragile than hardcoded names
yeah
but anyways, im gonna do that thing about groups
thanks bro