Hi, I'm trying to get an animation event to make a turn off call for a gameobject in middle of an animation. I figured that I get the gameobject via KickStarter.playerInteraction.GetLastOrActiveHotspot().gameObject, but still don't know how to create the message and send it.
I assume with this approach I can us the remember visibility and hotspot (or collider) to work in AC and save games.
The idea is to turn the game object player picks up off in a middle of taking animation.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
So the animation is on the Player?
IIRC, an animation event can only be used to trigger messages on the same object as the Animator, so you'll need to write a custom script that the event can call - and then use that to update the object you want to ultimately affect.
For example: create, and attach to your Animator, a new C# script that contains the following:
Then create an Animation event with the name "DeactivateLastHotspot" - the Console should bring the Debug.Log statement if run successfully. The code it actually runs may not be exactly what you want, but this is first about getting the function to be run in the first place.
Hmm. It works to get the object away, but the object returns when loading a saved game. I wonder if splitting the animation just before player grabs the object - and then delete it or send a turn off message would work?
Anyway I don't know which kind of approach to take to object taking, there seems to be all sorts of ways, but which work with AC...
Regardless of how you remove the object from view, you still need to flag it up using AC's Remember system in order to have it be saved correctly.
See the Manual's "Saving scene objects" for full details on this topic.
Having an object's presence in the scene is tricky, because you also have to make it a prefab that AC can spawn in if necessary.
It's much easier to teleport the object out of the way instead, i.e.:
You'd then just need to flag up the object's position for saving, which is a case of attaching the "Remember Transform" component.