So I need to dynamically instantiate certain objects in my scene, depending on whether the objects have been already picked up by the player or not. What I've done is to create a prefab with the object (which contains a hotspot). The objects are instantiated well so far.
The problem comes when I want to hook an action to the object's hotspot. I've created a parameterised action list asset for picking up objects in general, and that's what I want to set in the object prefab. I also create an additional prefab with the interaction so I can assign it to the hotspot (this prefab contains the parameterised actionlist asset). I can set it fine, but when I try to execute the action while playing, I get the following:
Coroutine 'EndCutscene' couldn't be started because the the game object 'Coffeelito_ Use' is inactive! UnityEngine.MonoBehaviour:StartCoroutine(String) AC.ActionList:CheckEndCutscene() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:563) ...
I certainly must be doing something wrong but am a bit lost at the moment... Any help?
Thanks!
Comments
Okay, what I'm trying to achieve is something quite typical: I want to place an object in the scene if and only if it hasn't been picked up by the player previously. This object does not necessarily need to be present in the scene since start/load.
Since this particular object won't be there at the beginning, I've made it a prefab (I don't want to put it as a scene object). This prefab contains a hotspot so I can interact with it. So far, so good.
Now to the prefab's interactions. Since picking up things is done quite often, I've created an ActionList asset named "Pickup", which is parameterised. I set the Interaction source to "Asset File" in the hotspot, and then link this new ActionList asset. But then, hey! My ActionList is parameterised and I can't pass the parameters from the Interaction in the prefab.
So I tried creating a prefab out of the interaction itself, and then is when I got this error. After your answer, I now understand that the interaction would need to be part of the scene. So how can I do this? Hotspot prefab + Parameterised ActionList asset.
I hope I explained myself well enough. Thanks!