playMaker

Author Topic: [SOLVED] FSM prefab doesn't run until deactivated/activated  (Read 920 times)

ArcherDan

  • Playmaker Newbie
  • *
  • Posts: 2
[SOLVED] FSM prefab doesn't run until deactivated/activated
« on: August 13, 2020, 02:25:44 PM »
Apologies if this issue has already been addressed somewhere, it cost me a few hours so posting for visibility.

I recently had an issue where I made an FSM prefab and was using it on a few instantiated objects in the scene just fine (basic rect transform set anchored position FSM for UI transitions). After adding a menu that is in the scene always, not instantiated, I noticed the FSM was visually updating but not doing anything in the scene. This seems related to similar issues containing the "State not in FSM!" error and prefab FSM attaching - although builds are affected as well.

My solution for now has been to simply to leave the gameobject inactive then activate it the first time it needs to be used.

Hope this helps someone! :)

ArcherDan

  • Playmaker Newbie
  • *
  • Posts: 2
Re: [SOLVED] FSM prefab doesn't run until deactivated/activated
« Reply #1 on: September 01, 2020, 09:47:27 PM »
Edit:
Unity 2019.4.8f1 Personal
PlayMaker 1.9.0

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: [SOLVED] FSM prefab doesn't run until deactivated/activated
« Reply #2 on: September 02, 2020, 04:23:58 AM »
Hi.
If you are instantiating the prefabs, you can't communicate with scene object directly.

So on instantiating you need to connect to the menu 1st.

there are a few ways to do this.

on creating, store the object and then use set fsm gameobject and set the menu object to a variable on the instantiated object (probably best way)

or

set your menu in a global variable and use that variable on your prefabs.

or

use find game object (slowest)