Godot Version
4.3
Question
Forgive me if all of this is convoluted, I am a new(ish) programmer that is self taught.
I have a class that extends Node2D called TargetingSystemComponent.
In this class is a variable called target with a Setter that emits the target_updated signal.
This target_updated signal gets handled by its parent
Once the parent catches this signal, it emits another signal based on the signal it caught called ship_updated, with the appropriate details of the component being updated. These details are then caught by the player’s Autoload Player class and it then handles the data appropriately to setup the UI.
This all works albeit possibly convoluted however where it fails is in the TargetingSystemComponent.
Whenever the target’s health reaches 0 and queue_free is called on the object the TargetingSystemComponent loses its reference to the ship ( as it should), however the setter property is never used as I assume the variable is not actually being set just because its reference was removed and thus the update signal is never emitted, causing a disconnect from the UI where it will still display the last data it had of the target that was destroyed, instead of displaying nothing.
This disconnect not only concerns my UI but the weapons that have a TurretComponent as well. Which also connects to the ships TargetingSystemComponent’s target_updated signal, to track and auto fire at the current target.
I am currently at a loss of what to do, outside of creating some additional functionality for the ships to have some sort of communication with each other prior to being free’d to resolve the issue I am having.
I guess this route would be the best one to take if I want to do things like reward exp or other things of that nature.
What is the best approach for this or alternatives to what I mentioned above.
Any help or guidance would be appreciated.
I also don’t understand why the property setter isn’t firing off when the variable changes.
For those who may leave code snippets to help resolve this for me, I am currently programming in GDScript but I know C# as well, either are fine to Sheppard me in the right direction.
Thank you.