I have a Transform on my Blackboard called “Target” that is set to a GameObject’s transform. When the GameObject is destroyed in the scene, the Blackboard correctly recognizes that “Target” is now null.
However, the CheckVariable<T> condition transition that compares “Target” to NONE thinks that “Target” is not null.
Under the hood, in CheckTransform<T>.OnCheck(), valueA.value evaluates to "null" (a string with the contents of “null”) rather than null, which causes this problem.
The problem stems from how Unity treats UnityEngine.Objects when they are deleted. I have added a special case in the CheckVariable to handle this situation and attached the fixed package for you here.
I notice that ObjectUtils.AnyEquals is also used in a few other places in the codebase — I haven’t seen any bugs from it yet, but do they need the same fix?
The source of the issue mostly comes from the fact that when a Unity object is destroyed, it is still kept referenced (which is normal). A more proper workaround fix for this would be to please open up ObjectUtils.cs and change method AnyEquals to this:
1
2
3
4
5
6
7
8
9
10
11
12
publicstaticboolAnyEquals(objecta,objectb){
//regardless calling ReferenceEquals, unity is still doing magic and this is the only true solution (I've found)
This should handle the null checks with unity objects better and of course for all cases AnyEquals method is used (thus no need for the first fix I sent you any longer)
Let me know if that works for you.
Thanks 🙂
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.