playMaker

Author Topic: "Send Message" action loses reference to specified GameObject in Templates  (Read 1565 times)

louismg

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
FSM is instanced from a template.
I drag a GameObject in a "Send Message" action.
I run the game and it works fine: the message is sent.
I save the scene. Close it. Reopen it.
The GameObject is now "None".

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: "Send Message" action loses reference to specified GameObject in Templates
« Reply #1 on: December 07, 2013, 08:17:58 PM »
You can't communicate from prefabs to the scene or vice versa. They both have to exist in the scene. Common Unity limitation.

louismg

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Re: "Send Message" action loses reference to specified GameObject in Templates
« Reply #2 on: December 07, 2013, 09:31:58 PM »
 :(

So can you instead instantiate a prefab at runtime and pass it parameters it can use? If not, how would do you pass scene context to prefabs?

Here is my concrete case.  I have a car showroom with 3 platforms. Each platform has 3 cars on it. Playmaker totally controls the scene: i.e.: which platform the camera is pointing at and the rotation of each platform to put one particular car of said platform in front of the camera.

I use FSM templates  a lot because there is a lot of repetition in here (3 platforms, 9 cars)

Now in the C# scripts, I need to know the state of the showroom.  But the prefabs can never communicate what's going on because I can't give them references like a pointer to the car object or the car index of each platform.

So I have this very convoluted method where the prefabs call an FSM that is not a prefab (so in which I can manually go and set indexes and pointers to GameObjects) which then sends a message with the context to the C# room manager.  Hell...

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
    • View Profile
Re: "Send Message" action loses reference to specified GameObject in Templates
« Reply #3 on: December 07, 2013, 10:04:39 PM »
Yes, all you have to do is instantiate the prefab into the scene at runtime. Then just get a reference to the instantiated version and pass it the parameters you want. Done.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: "Send Message" action loses reference to specified GameObject in Templates
« Reply #4 on: December 08, 2013, 07:57:29 AM »
I sometimes make a manager object that is always in the scene with a specific name that i can pass variables through as soon as a prefab is created.

But anything works as long as you do it with scene objects, just don't drag and drop between scene and project.