playMaker

Author Topic: Spawning prefabs that reference other in scene prefabs[SOLVED]  (Read 2201 times)

Roger Lee

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Spawning prefabs that reference other in scene prefabs[SOLVED]
« on: October 03, 2012, 03:22:16 PM »
First off I would like to start by saying I love Playmaker.  I am a amateur Visual Basic programmer and I really don't have the time to dedicate to fully learning C# or Java.  Playmaker is exactly what I needed to play around with some ideas in Unity.

I have gone completely through the AI tutorial from Bad Seed Games and I'm running into one single stumbling block.  I use the Ultimate FPS Camera for my player controller object.  To build an enemy that chases the player I have to reference that object in one of the enemy FSMs.  Everything works perfectly as long as the enemies are setup in the scene hierarchy, but once I make that enemy a prefab for later spawning, it loses the game object that it's intended to chase.  So once I spawn this object again it doesn't know what to attack.

I have tried creating a global variable gameobject and setting my FPS controller to it.  But when I reference that variable on the enemy, it doesn't see it or chase it.  

How is this done in Playmaker?  I can't imagine that it's not possible to spawn a prefab enemy and it know what it needs to attack in the current scene (another prefab).

Thanks in advance and thank you for a wonderful product!!
« Last Edit: October 03, 2012, 09:41:22 PM by jeanfabre »

Roger Lee

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: Spawning prefabs that reference other in scene prefabs
« Reply #1 on: October 03, 2012, 03:50:10 PM »
I've been working on this problem for three days now and as soon as I post this question I find the solution 10 minutes later!!!

The way I made it work was by inserting a state at the beginning of the radar FSM.  In the state I used a "Get Game Object" action.  For some reason by using this action and then storing the object in my previously setup global variable it worked and the enemy could see my player object.

It just needed to find the gameobject at runtime apparently.

Thanks anyway!!