playMaker

Author Topic: Help! FsmObject's Value is always Null.  (Read 201 times)

human890209

  • Junior Playmaker
  • **
  • Posts: 62
    • View Profile
Help! FsmObject's Value is always Null.
« on: August 29, 2017, 09:03:14 PM »
Hi,
I'm using a FsmObject variable. Its value always return null! Help! I'm not a programmer, hope someone good at it could help me out!

In my action script, before doing the real thing I wrote this to initialize the FsmObject.
if (ABC.value == null)
{
    Debug.log("ABC.value is null!")
    ABC.value = new MyObject();
}

MyObject is a simple class:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
   public class MyObject: Object {
      public bool b;
      
      public MyObject()
      {
         this.b = true;
      }
   }
}

Every time my Action is entered or using everyFrame. I got this "ABC.value is null!" log and the ABC.value are reset. I can't store the result into the ABC FsmObject variable. :(




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Help! FsmObject's Value is always Null.
« Reply #1 on: September 01, 2017, 04:17:50 AM »
Hi,


it could be that you need to add an attribute for it to be serializable.

https://docs.unity3d.com/ScriptReference/Serializable.html


or Unity objects are special ( buggy in their implementation...) and == null doesn't work in some cases.

can you try this:

 aObj == null || aObj.Equals(null);
   

it could be also that initializing the object like that doesn't work. can you do that on Reset() instead?


Bye

 Jean