This might get a bit confusing - I have created a “cutscene handler” that handles conversations (setting text via typewriter, fading conversation sequences in and out, etc etc) made up of scene “block” structs in a scriptable object, and a handler that goes through these blocks and plays them in order. This has been fairly effective for getting my cutscenes set up, but I’ve run into a snag: incorporating more “animated” animations.
For context, my player character is in a scene of their own, and scenes are loaded and unloaded additively as the player transitions between areas.
So now, I am trying to come up with a way of creating cross-scene animation sequences. The scriptable objects are, obviously, scene-agnostic, but each scene will obviously need to have the required characters (and whatever else) in place to be able to be animated.
Timelines looks like it might have what I need in terms of creating animations, and I’ll probably need to craft multiple timelines and play them all simultaneously in order to create these cross-scene animations, right? However, I’m just getting started and don’t really know what’s possible.
Luckily right now all I care about is making an NPC play a single animation as part of an animation-sequence block. How could I, for example, create a cutscene where my player (from the Player scene) runs up to this NPC, and then the NPC plays its animation (along with some VFX and SFX), and plop all that into my SO that is then handled by my handler?
It seems to me that I would need to create a timeline for my player which handles translation and sets the animation - and do the same for my NPC’s scene - and then just play them in order. But that seems too simple. Maybe I’m just having trouble wrapping my head around how a Timeline would animate my character properly, because so far all I’ve figured out is I can drop an animation in there, but it has no reference to the character or even the character’s scene and I know that there’s no way it would work.
Luckily I do see that I can drop timelines into the SO so as long as I can tie them to the proper character and scene, playing sequential animations should be simple enough. I think that’s the key detail that I’m missing.
Edit: Okay, looks like I’m looking at Playable Directors, but they can only play one timeline asset at a time… so maybe one director for each timeline asset? Or, I have to create a timeline that has all the appropriate animations in order? Looks like Playable Bindings might help as well, still investigating…
Edit 2: Okay; it’s looking more like I need a playable director on each gameobject that I want to animate, as well as for each track I want it to be able to control? This is swiftly becoming very convoluted, especially because even if I do that, I still have to somehow use my SO to identify which Directors need to play which Timelines, and it has no knowledge of the non-asset Directors across scenes. I still feel like there’s something I’m missing here…
Edit 3: Okay. This is the crazy idea I’ve come up with.
- Create a Playable Director for each timeline on each character that needs to have these animations played.
- Add the timelines into the SOs.
- When it comes time to play the animation, search for every loaded playable director and check its playable asset. If it has the same timeline as the SO, play that playable director.
I think it’ll work, but it’s ugly and implementation is going to be a pain, which I will try to get to tomorrow. But working is working…