I think I understand…
Instead of the player iterating through and calling all of its abilities, the ability just connects directly to whichever signal it needs on the player?
My current setup is to add each Ability as a node to the player, so right now it follows the “call down, signal up” adage that I hear everyone say. What would be a good way to implment the other way? I assume I should rework my current setup otherwise it’d be “signal down, signal up”?
Win11 doesn’t let you past setup if you dont have an internet connection.
Thanks for your input! The other commenters pointed out that I can use Godot’s is_instance_valid()
function to check if the bullet’s owner exists before attempting to call anything on it, so will be reworking the system to use #2 + that.
Definitely sounds like the way to go the more I think about it. Thanks!
The longer I’m using the signal chain the more I’m wanting to rework it to just be a reference lol. Good point with checking if the instance is valid, if any other errors come up I could just patch around them in a similar fashion.
That said, you can probably simplify your signal code if you connected the bullet killed_enemy signal directly to the player’s on-hit handler. It seems like the weapon on-kill handler is redundant?
Ah I see what you mean, killed_enemy(enemy-object) signals directly to the player which can then pass that enemy to it’s abilities if needed. You’re correct that the weapon signal is mostly redundant, it was just the easiest node to connect to the bullet’s signals, as it’s responsible for spawning them.
I think I’ll change the whole system to just use a reference. Thanks for your input!
You’re probably right, but it’s an alternative for people who don’t.
Just tried this out in one of my projects, here’s what happened:
do something
works without a problem.do something else
never goes off.foo()
again any number of times and do something
will still go off.Having it waiting in the background didn’t seem to have much of a performance impact. I started 5000+ of them and foo()
only took up ~0.6% frametime with the rest of my game running alongside it.
Don’t know if this will achieve what you want, but I selfhost ChangeDetection.io to check if webpages have been updated, then subscribe to changedetection’s RSS feed with FreshRSS.
I patched together some version of this using nested dictionaries:
with each value being another key:value pair of
{ "ability_id": <ability-node> }
so I can keep a reference to the Ability node and use dictionary functions like .has() to check if a character has a specific ability:Then when a trigger fires, it calls this (I omitted the return code):
This seems to work, but it still gives me that tickling sensation that it could be a little cleaner.