Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: louismg on December 07, 2013, 10:09:02 PM

Title: "Send Message" action loses reference to specified GameObject in Templates
Post by: louismg on December 07, 2013, 10:09:02 PM
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".
Title: Re: "Send Message" action loses reference to specified GameObject in Templates
Post by: Lane on December 07, 2013, 10: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.
Title: Re: "Send Message" action loses reference to specified GameObject in Templates
Post by: louismg on December 07, 2013, 11: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...
Title: Re: "Send Message" action loses reference to specified GameObject in Templates
Post by: dasbin on December 08, 2013, 12:04:39 AM
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.
Title: Re: "Send Message" action loses reference to specified GameObject in Templates
Post by: Lane on December 08, 2013, 09: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.