playMaker

Author Topic: Prefab FSM referencing children objects  (Read 2498 times)

thatnzguy

  • Playmaker Newbie
  • *
  • Posts: 43
Prefab FSM referencing children objects
« on: October 20, 2015, 05:30:36 PM »
I have a FSM on a prefab that references children of the prefab. This breaks the "Playmaker FSM Prefabs cannot reference scene objects" rule, however it works because, I think, Unity is smart and fixes up the connections when it instantiates the prefab in the editor.

This has been working fine for me until I attempted to use a template for this FSM, now I get Playmaker UI errors about prefabs referencing scene objects.

Perhaps Playmaker should allow prefabs to reference scene objects if they are inside the prefab?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Prefab FSM referencing children objects
« Reply #1 on: October 21, 2015, 01:38:16 AM »
Hi,
as far as i know that is not be possible because it is also not possible in unity coding

Quote
No, that's not possible because prefabs are assets and they can't rely on objects in a certain scene.

thatnzguy

  • Playmaker Newbie
  • *
  • Posts: 43
Re: Prefab FSM referencing children objects
« Reply #2 on: October 21, 2015, 04:24:11 PM »
Here is a simple example:

1. Create an Empty GameObject called "Root"
2. Create an Empty GameObject as a child of Root, called "Test1"
3. On Root, create an FSM with one state
4. Add action Debug GameObject, on GameObject field create a variable called TestObject1.
6. Assign TestObject1 to Test1
7. Turn Root into a prefab
8. See that in both the Scene, and the Project Window that TestObject1 is set to Test1.
All is well, a prefab is referencing another gameobject which happens to be it's child.

Then:
9. Turn the Root FSM into a Template.
10. See errors on the Debug GameObject action about referencing scene objects.

ManicMinerUK

  • Junior Playmaker
  • **
  • Posts: 51
Re: Prefab FSM referencing children objects
« Reply #3 on: October 21, 2015, 08:40:44 PM »
I think the "error" you are seeing is really just a warning - I also suspect that if you actually instantiate the prefab described before making the FSM a template, you will find that whilst it will appear fine in the editor, it might well lose its references at runtime.

Or it might not, Unity can often retain references if they are entirely contained within the prefab and don't move outside it - it depends how the prefab is constructed I think

If you really need a template to talk to its children in its prefab, you are probably best using the "child count" stuff in Playmaker to do it

thatnzguy

  • Playmaker Newbie
  • *
  • Posts: 43
Re: Prefab FSM referencing children objects
« Reply #4 on: November 02, 2015, 04:35:19 PM »
Yeah it's just a warning, I'm hoping the devs can suppress this istance of a warning so I can use it without our project filling with these warnings