playMaker

Author Topic: Prefabs within Prefabs within....  (Read 2686 times)

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Prefabs within Prefabs within....
« on: June 13, 2017, 09:02:22 PM »
I must be doing something wrong. Anytime I try to use Prefabs in a project, it turns into a rabbit hole with no end.

I make Object X into a Prefab so I can use it over and over in the game, but then the connections break. I can only fix the connections IF:

1. I turn the SECOND game object its OWN Prefab.
2. I use Find Game Object and set the Second Game Object as a variable........
Which can only be done if I first turn it into a Prefab!

So it seems to me that if I make one thing into a Prefab, more game objects will have to be converted into Prefabs as well.

Am I missing one crucial element that stops the Prefab growth cycle?

Much obliged.

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #1 on: June 13, 2017, 09:10:29 PM »
Also, as a follow up, it seems that when I do convert the object into a Prefab, the events I thought were going to be sent to the original object, are being sent to the Prefab version of the object. And if the Prefab version of the object is not in play, then the sent event is going into a black hole.

Is that correct?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Prefabs within Prefabs within....
« Reply #2 on: June 14, 2017, 12:09:32 AM »
Hi,
they indeed break when you convert them into prefabs, same way as c# scripts would break.
But there are several ways that you can communicate with the prefabs if you create them @ runtime you can place the prefab into a variable and/or array list.
to get (for example) an int value you can use 'get fsm int' and set "Game Object" to the variable.
set the fsm name and the variable name and you can store the value in a variable.
if you search in the action for 'fsm' you can find many actions you can use :)

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #3 on: June 14, 2017, 08:04:34 PM »
Awesome, thanks! I've reconnected the Game Objects within the FSMs.

Trouble that I'm having now is that since everything in my scene is now a Prefab, nothing seems to trigger. Before I started to change things into Prefabs, they fired just fine. But now as soon as the first Send Event needs to be sent, everything stops. Is there something off with my setup?

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #4 on: June 14, 2017, 08:05:29 PM »
This is the Health Manager.

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #5 on: June 14, 2017, 08:06:26 PM »
This is the Bomb that should be created.

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #6 on: June 14, 2017, 08:07:37 PM »
This is the String that's supposed to change with each step of the Question Stage.

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #7 on: June 15, 2017, 06:41:12 PM »
Would it help if I attached the scene file?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Prefabs within Prefabs within....
« Reply #8 on: June 16, 2017, 01:19:16 AM »
Hi,
I can not see if the connections are good or bad...but you can test some things :

On the 'send event' action Click on the gameobject that is in that action,
it will be highlighted in the Hierarchy, so you can see if it sends to the correct object.
You can also do this with other actions that have object or components in it.

Also you can right-click on state and set a break point, if the game reaches that state when played it will pause and focus to that state, this way you will know that the state is triggered.

You Can also right click on a transition then click on send by, so you can see where the transition is triggered from (from a 'send event' action for example)


You can break the prefab by selecting a prefab in the Hierarchy and then 'GameObject>Break Prefab Instance' in the top bar.

You should also always(!) make backups from your projects so you always can go back if something went wrong.
I learned that the hard way and lost months of work...

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Prefabs within Prefabs within....
« Reply #9 on: June 16, 2017, 06:00:09 PM »
Thanks for the feedback! I'll take a look and test the things you mentioned and I'll let you know how I go in my progress.

In the meantime, can you take a look at the scene file and let me know if the connections are ok? It might be faster than sending pics.

Only if you have the time. I really appreciate your help.

Thanks again!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Prefabs within Prefabs within....
« Reply #10 on: June 17, 2017, 01:41:20 AM »
Hi,
i can't do anything with that file because the "prefabs are missing"

2 things you can do :

Before you do anything make a backup of your project...

1:
If they are standard objects: highlight the prefabs in your hierarchy,
Then on the top bar click on "GameObjects, then on "Break Prefab Instance"
After that you can remove the prefabs in your project folder. (only the ones that you don't need as a prefab.

2:
deselect everything in you project window, then right-click on an empty space in your project window and select  'Export package...' (or go in top bar and select 'Assets' and 'Export package.)
Then Deselect :
-Gizmos
-itween
-playmaker (*)
and inside the plugin folder deselect
-playmaker (*)
(*) inside these folders are files called PlayMaker.dll. These are not allowed to be shared.

and press Export...

this file will be bigger and you need to upload it somewhere and share the link.