Playmaker Forum
Bug Reporting => PlayMaker Bug Reporting => Topic started 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".
-
You can't communicate from prefabs to the scene or vice versa. They both have to exist in the scene. Common Unity limitation.
-
:(
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...
-
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.
-
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.