TL;DR : How do I elegantly check whether animations are done or from all sorts of objects and weave that into my BattleManager Script?
I am wondering how a professional would go about weaving the scripting of a state machine into the Battle Scene Intro of say, Pokemon.
You know where the Pokemon sprite spawns and it slides in from off screen still shadowed, then fades in, then your battler throws a poke ball out your Pokemon comes out, then when all is said and done then your state starts with Players turn, waiting for the players input.
I am currently building such a system, and while I can give objects their own animations, because theyre on different Objects, I can’t add a keyframe on the animation to run a method when done, I thought about setting bools and one by one getting the components and checking if their animation is finished, but all my thought processes lead to some hacky looking code.
Could anyone please, point me in the right direction? A tutorial or guide, or perhaps a little bit of your own knowledge?
Or is it just one really long animation of the entire canvas?
Take a look at Cinemachine (now part of Unity). It’s designed for smoothly blending between cut scenes and gameplay.
And also Timeline. Timeline and Cinemachine were designed to be used together to make complex sequences exactly like you’ve described.
Ahh, awesome suggestions, thank you very much, I just checked them out, I should easily get what I wanted done. I am still really curious how people code these though, because not everyone uses unity and not everyone has Cinemachine and Timeline. I guess they create their own?
Well, having worked with a variety of proprietary engines, the process goes something like this:
Art/design team: “We have this idea for an awesome transition from the intro cut-scene to the game! All we need to make it happen is a, b and c! That should be easy, right?”
Engine team: “Okay, but what about d,e, f, and g through n?”
Art/design: “Oh, right, we’ll need those too.”
Engine team: “Fine, we’ll make a system for that.”
… 3 months later…
Engine team: “Okay, here’s the awesome system you requested!”
Art/design: “Oh. Right. Yeah, we changed how we want to do those, now we need a different system that does x, y, and z. That should be easy though, right?”
…Return to step 1, repeat as needed…
Before Timeline was introduced, one of Unity’s big shortcuts for making sequences was a type of function called a coroutine:
Basically it’s just an ordinary function call except you can “yield” the execution at any point and resume execution later. For example, if you had an animation that lasted 4 seconds, you could write code to start the animation, yield for 4 seconds and then there’d be code to do the next thing, etc.
@PanicEnsues
I can imagine that, you see it now even on discords, people seem to think other peoples jobs are simple and easy to change on a whim.
@kdgalla
That was the route I was heading, but yeah, the code just felt so choppy and seemed so open to errors.
I’m using Timeline with it’s signal system and its definitely getting the job done in a much cleaner manner. I feel like I have a lot more on demand control