playMaker

Author Topic: Set FSM Variable not working?[SOLVED]  (Read 1960 times)

evilpikmin

  • Playmaker Newbie
  • *
  • Posts: 16
Set FSM Variable not working?[SOLVED]
« on: July 01, 2019, 10:30:36 AM »
Can anyone confirm if this is working as I'm not 100% sure its not just me doing something wrong? I am using version 1.9.0.p16 of Playmaker and Unity 2019.1.6f1. After doing many tests on simple objects, I cannot set an FSM variable on a prefab from another prefab. should be simple right?! If anyone could confirm either way it would be helpful for my sanity :)

forgot to add that it is only an issue while trying to do this on prefabs. setting across gameobjects works fine.
« Last Edit: July 05, 2019, 10:19:34 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set FSM Variable not working?
« Reply #1 on: July 01, 2019, 11:53:49 AM »
hi.
If both prefabs are in the scene and then you drag in to reference it will work.

But if prefabs are created @ runtime this will not work.

Object in project folder can not communicate directly to object in the scene/hierarchy

So when Prefab is spawned it will need to get a reference to that object 1st.

There are a few ways that you can do this:

Use the "Find game object".
But if you need to do this many times, its bad for performance.

Or

When creating a prefab, store the created prefab in a variable, the use 'Set Fsm Game Object' to set the game object that you wish to reference on that prefab.

There are some other ways as well but the 2nd option might be the best to use.

This is a unity limitation by the way

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Set FSM Variable not working?
« Reply #2 on: July 01, 2019, 01:20:50 PM »
When creating a prefab, store the created prefab in a variable, the use 'Set Fsm Game Object' to set the game object that you wish to reference on that prefab.

Ah this is brilliant. This is why I read random threads here, just in case there are any good tips passed on.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set FSM Variable not working?
« Reply #3 on: July 01, 2019, 06:28:44 PM »
Hi.
@daniellogin
Maybe you should start a post on the tips and tricks section to bundle what you found :D

evilpikmin

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Set FSM Variable not working?
« Reply #4 on: July 03, 2019, 03:57:29 PM »
Thanks for the reply that was super helpful. I'm starting to understand how to do stuff without using global variables now!

cheers