playMaker

Author Topic: How to Use "SetFsmTemplate" Method??  (Read 1526 times)

blbee

  • Playmaker Newbie
  • *
  • Posts: 1
How to Use "SetFsmTemplate" Method??
« 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");
    }
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Use "SetFsmTemplate" Method??
« Reply #1 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