3 ms·
Yes, but read further, there is no method to test whether the object I pointed to still exists. You have to listen for a signal that the object is leaving the s
by jay_kyburz 5y ago
Yes, but read further, there is no method to test whether the object I pointed to still exists. You have to listen for a signal that the object is leaving the scene and manually clear your reference.
- thaumasiotes 5y ago> there is no method to test whether the object I pointed to still exists There probably is such a method, but you'd have to invoke it on the object, not on some other unrelated object.
- nightowl_games 5y agohttps://docs.godotengine.org/en/stable/classes/class_%40gdscript.html#class-gdscript-method-is-instance-valid https://docs.godotengine.org/en/stable/classes/class_%40gdsc... I'm making a complex Godot game. 'is_instance_valid' does what you are describing.
- jay_kyburz 5y agoOnly in Debug builds. If you rely on it in a release build you will crash. https://github.com/godotengine/godot-proposals/issues/1589 https://github.com/godotengine/godot-proposals/issues/1589 https://github.com/godotengine/godot/issues/41179 https://github.com/godotengine/godot/issues/41179 Reduz doesn't want the fix in release builds because the will be slower!
- nightowl_games 5y agoI don't understand. That's not what that PR says. That PR is about using == null. It offers no substantial information about is_instance_valid.
- jay_kyburz 5y agoApologies, you might need to do some digging and research on your own. On Oct 2 @RandomShaper said "is_instance_valid() was made thread-safe, but it's still not something you can trust. An object allocated at the same address as a freed one will report a false positive. That's, of course, considering that what you want to check is that your variable is still pointing to the object you assigned, and not to just some object, which I think is the case. @reduz respoinded with "Ah that may be still the case of 3.2, but in 4.0 this function is 100% trustworthy"