I am confused about some of the default tasks, prefabs and gameobjects. I was hoping someone could provide a little guidance on this.
I have a prefab that is referenced in multiple scenes and I want to associate a tree with it so that the same behavior is consistent in each scene. So on my prefab I create a behavior tree and I set up the tasks. Everything works great until I want to use the GetFieldValue, SendMessage and Invoke tasks.
Note: gameobjects are created during runtime so I really want to use prefabs to solve this and not gameobjects in each of the scenes.
I have tried several approaches to try to get this to work. Here is one of my attempts.
With GetFieldValue, I drag the prefab from my project view into the task inspector and I am able to see a list of components and select a field. Cool. And when running the project the correct gameobject from the scene is referenced and the field value is retrieved without error.
Note: I was wrong. GetFieldValue works but not how I want it to. I want it to reflect the gameobject associated with the prefab in the scene. At runtime it continually returns the prefab’s initial value.
With Invoke, if I drag a prefab from my project view into the task inspector I am NOT able to see a list of components in order to select a method. I am only able to view the components if I select a gameobject from the scene.
With SendMessage, I am able to select my prefab but at runtime I get a “SendMessage mymethod has no receiver!”
Any advice appreciated.