|Topic was automatically imported from the old Question2Answer platform.
I want to pass a value from one object to the next. The problem is that it looks like there is no way to do this cleanly. This is what I have deduced after reading the manual on finding nodes:
Green shows what I want. I will first need to ask the parent for a list of children, then tell it to change the value in the child.
I can’t use the hard code path system Godot wants me to, the whole getNode(“Path\Path”) thing, because my game will have objects spawning dynamical.
Searching every object in the scene to find one would be slow.
This image shows my setup for now, but it won’t stay this simple.
Also looks like Godot has no way of selecting object at run-time? Feels like I am missing something big here.
I had something like this a while ago, but it involved collision, so it was not that problematic. If You have a collision there, then You easily get the node that collided and can immediately connect+emit a signal to it or just call it’s method directly.
For a totally abstract setup I’d probably keep a list of As and Bs in Level node for fast access and I would probably keep a reference to Level node in every other node also for fast bug-free access.
It is hard to say on which particular condition You do select A2 for B2, but maybe they are related in some way - like collision, ray cast, adjacency - which could help get the reference instantly.
My answer is based on two weeks of experience in GODOT, so maybe there would be someone smarter to help :).
Thanks to you , I managed to solve it. As you say I use collisions, for this to work the script must be attached the the parent node, because it is the only node that knows where the children are.
In other words, it works in reverse from what I was attempting.
Looking at how buttons work and how Godot checks every item one by one for input, it is safe to say that this is intended. So I assume it has a octree or something.
Thanks for pointing me in the right direction.
MysteryGM | 2018-09-06 12:48