I’ve encountered a strange issue when working with the Behavior package version 1.0.2. Specifically, I’m trying to check whether a BlackboardVariable.ObjectVariable is null. However, a direct comparison to null returns false, which is unexpected.
For context, when I run:
Debug.Log(BlackboardVariable.ObjectValue);
It logs null as expected, but if I try:
if (BlackboardVariable.ObjectValue == null)
{
// Never enters this block
}
The comparison fails. After some trial and error, I found that the only way I can reliably check for null is by doing the following:
if (BlackboardVariable.ObjectValue.ToString() == "null")
{
// This works
}
For context, I was trying to write simple null checking condition:
public partial class IsNullCondition : Condition
{
[SerializeReference]
public BlackboardVariable Variable;
public override bool IsTrue()
{
return Variable.ObjectValue == null;
}
}
This feels like an odd workaround, and I’m not sure why the direct comparison doesn’t behave as expected. Has anyone encountered a similar issue, or does anyone have insights into why this is happening? Any suggestions for a cleaner approach would be greatly appreciated.