Playmaker Forum

PlayMaker News => General Discussion => Topic started by: human890209 on August 30, 2017, 12:03:14 AM

Title: Help! FsmObject's Value is always Null.
Post by: human890209 on August 30, 2017, 12:03:14 AM
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. :(



Title: Re: Help! FsmObject's Value is always Null.
Post by: jeanfabre on September 01, 2017, 07: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