playMaker

Author Topic: Cant use my Pre-Fabs  (Read 1959 times)

cookimage

  • Playmaker Newbie
  • *
  • Posts: 6
Cant use my Pre-Fabs
« on: January 16, 2013, 06:34:58 PM »
Question I have written some FSM 's and in some I have a function that for instance calls a specific game object, but if I save my objects as pre-fabs and drag them into a new scene, those call does not have the object in them any more and I have to reconnect them. Problem is how will you be able to carry a player object over to other scenes, if say for instance your mobs call on the player object, but it is not there until you go into the scene?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Cant use my Pre-Fabs
« Reply #1 on: January 17, 2013, 01:02:18 AM »
Hi,

 Yes, It's a Unity restrictions actually, a Prefab can not reference directly objects from the scene, it can during runtime, but it can not store them as a prefab within the "assets".

 to achieve this. Either maintain global variables and then your prefab read that global var, that works. I much prefer a more versatile approach using events. At some point you will have to instantiate this prefab, when you do, simply call that prefab passing on information about that gameObject reference, and mayn other things as well if required. The opposite works too. When your prefab FSM  starts, have the prefab go an get the info it needs. It can do either by finding the gameObject using the action "Find" for example.

bye,

 Jean