News for hackers. Stuff that matters.
Re:Game Engines on Steam: The Definitive Breakdown by jay_kyburz on Thursday September 02, 2021 @08:35PM (#28399184)
Sure, there are easy workarounds, but the issues are unexpected and secret (and now only in release). In any other scripting language I've worked on you can do some test on a reference to see if its null or doesn't exist. In Godot you have to listen for the object reference leaving the scene.

I can guarantee this is not an issue in Unity where a object that has been removed from the scene is null.

Re:Game Engines on Steam: The Definitive Breakdown by kevingadd on Thursday September 02, 2021 @09:13PM (#28399395)
As it happens, Unity has its own version of this problem, where it pretends that a non-null dangling reference is a null-reference: https://jacx.net/2015/11/20/dont-use-equals-null-on-unity-ob...
Re:Game Engines on Steam: The Definitive Breakdown by jay_kyburz on Thursday September 02, 2021 @10:03PM (#28399663)
That is not the same at all. The equivalent would be that your reference is pointing to some other object in the scene.
Re:Game Engines on Steam: The Definitive Breakdown by thaumasiotes on Thursday September 02, 2021 @09:41PM (#28399556)
> In any other scripting language I've worked on you can do some test on a reference to see if its null or doesn't exist.

Except - and this is called out in the github thread - the reference is not null and does exist. The check is working correctly.

The problem lies in the fact that what you want to check for is "is the object I originally pointed to still around?", but instead of doing that, you're checking "is the thing I'm pointing to currently a valid object?".

Re:Game Engines on Steam: The Definitive Breakdown by jay_kyburz on Thursday September 02, 2021 @10:07PM (#28399679)
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.
Re:Game Engines on Steam: The Definitive Breakdown by nightowl_games on Friday September 03, 2021 @02:14AM (#28400974)
https://docs.godotengine.org/en/stable/classes/class_%40gdsc...

I'm making a complex Godot game.

'is_instance_valid' does what you are describing.

Re:Game Engines on Steam: The Definitive Breakdown by jay_kyburz on Friday September 03, 2021 @03:10AM (#28401248)
Only 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/issues/41179

Reduz doesn't want the fix in release builds because the will be slower!

Re:Game Engines on Steam: The Definitive Breakdown by nightowl_games on Friday September 03, 2021 @11:19AM (#28405384)
I 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.
Re:Game Engines on Steam: The Definitive Breakdown by jay_kyburz on Friday September 03, 2021 @04:33PM (#28409055)
Apologies, 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"

Re:Game Engines on Steam: The Definitive Breakdown by thaumasiotes on Friday September 03, 2021 @01:37AM (#28400747)
> 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.