Currently working on my game, for a feature I need that x number of bots know the position of all the other bots and some static objects relative to themselves, discern the shortest one and move towards it.
I made this sketch to try and explain what the system currently looks like. It’d require at least like 2 signal calls per frame (or an interval close to that) for every single bot entity currently loaded, I currently plan on about 14 but I want to know what you guys think about the amount of signal calls required, because I’m quite unsure how resource intensive they really are and I don’t know another method to get all the position of a node separate from itself without instantiation.
I don’t know the limits (that makes it laggy for a ‘standard’ system) but 14x2 = 28 signal calls should be very ok.
EDIT:
of course unless you are not doing something extremely heavy for each call, like running a pathfinding algorithm 100s times per signal. then it may cause a problem. But the overhead on the call itself is neglicable in this scale.
Emitting a signal takes about as much time as a normal function call. So if a signal has one function connected to it then it takes about as much time as two function calls (calling emit() itself + the connected function).
So no, it shouldn’t be a problem.
(Assuming it really has to be signals, and you can’t get the positions like bot_a.position)
I think there is a more performant solution… thinking out loud, I would use an array of bot locations, and have each bot update their entry. You can then use this array for each bot to determine the closest without flooding signals to each.
As @Monday already hinted, signals are just function calls. Connections cost nothng in terms of performance and very little in terms of storage (a callable reference per connection), and emitting cost a function call per connection.
So connect as much as you like and don’t worry about it. Your focus should instead be on architecting those connections in a well organized hierarchical fashion.