Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | cardoso | |
Old Version | Published before Godot 3 was released. |
I’m trying to check if an array already has a weekref to a character/node before adding that character’s weak reference to the array.
Something like this:
if !array.has( weakref( char ) ):
array.push_back( weakref( char ) )
But it always adds the new reference of the same character (so the array just gets many more weakrefs to the same character). I’m guessing that there can obviously be many different weakrefs to the same character/node.
Is there a way to compare 2 weakrefs?
If not, what can I do? (If instead of weakrefs I add the character itsself to the array, it might cause issues when that character is freeded/deleted.)