Hi!
I have a spot light that I have placed on the player prefab on the head bone so that it will move along with the players head motion. I have a trigger to turn it on/off on entering the trigger. I was using the Object:Call Event -> GameObject.SetActive to turn this on/off. This all works fine as long as I have a local copy of the player prefab. As soon as I delete the local prefab this no longer work. Im not really sure what im doing wrong. Please help!
Thanks!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @eraser2822.
Most Actions are able to use AC's Constant ID system to link prefabs with their scene-based counterparts, by recording the Constant ID value of the assigned objects, and then searching for that value at runtime.
The Object: Call event Action, however, is the exception - because it relies on Unity's own event system. For this Action to work, you have to ensure that the connection is always unbroken, i.e. the object you assign in the Action will be the only one that can be directly affected.
It's also best to disable individual components - rather than entire GameObjects - so that AC doesn't lose references to objects at runtime.
To toggle the enabled state of a Light, it's better to attach AC's Light Switch component, and then use the Object: Send message Action to pass "Turn On" and "Turn Off" messages to it.
Alternatively, you could control the Light's enabled state in a sub-layer of your Player's animator, use Animator parameters to trigger transitions between on/off states, and then control these parameter values with the Character: Animate Action.
To save the light's enabled state, you'd also need to attach the Remember Light component (for the first method; see this tutorial), or the Remember Animator component (for the second method).