Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: blbee on April 19, 2015, 05:43:49 AM

Title: How to Use "SetFsmTemplate" Method??
Post by: blbee on April 19, 2015, 05:43:49 AM

Use Some Object By ObjectPooling

* sequence

1. 'A' Object Create
2. 'A' Object set PlayMaker FSM - SetFsmTemplate("someTemplate");
3. After a short period of time.
4. 'A' Object setActive (False) - Instead destroy

5. 'A' Object setActive (True) - Instead create
6. 'A' Object set PlayMaker Fsm - SetFsmTemplate("someTemplate");

but, Strangely it works.

Code: [Select]
public class ApplyTemplateTest : MonoBehaviour
{
    public PlayMakerFSM targetFsm;
    public FsmTemplate testFsmTemplate;
   
    public void OnEnable()
    {
        applyTemplate();
    }


    void OnDisable()
    {
        targetFsm.enabled = false;
    }


    void applyTemplate()
    {
        if (targetFsm != null && testFsmTemplate != null)
        {
            targetFsm.SetFsmTemplate(testFsmTemplate);
            targetFsm.enabled = true;
        }
    }
}

Code: [Select]
public class playmakerTest : MonoBehaviour
{
    public GameObject testMonsterObject;

void Start ()
    {
        StartCoroutine("enableChage");
}

IEnumerator enableChage()
    {
        yield return new WaitForSeconds(1.5f);

        testMonsterObject.SetActive(!testMonsterObject.activeSelf);

        StartCoroutine("enableChage");
    }
}
Title: Re: How to Use "SetFsmTemplate" Method??
Post by: jeanfabre on April 21, 2015, 02:13:15 AM
Hi,

 Can you describe how you would like this to work and how you experience it? I am not sure what you want to know. I never used this method myself, but it sounds like a very interesting way to change behavior.

Bye,

 Jean