"Scripted" animations in 2d game

Hello,

I’m working on a 2d adventure game ( as in the old school point and click games) and I am wondering what is the best way to approach scripted animated events in the game.

For example, when a scene starts, during the ‘cinematic’ part, I want to have 2 npc characters enter the scene, have a chat and leave. And later during the game , when you trigger an event (by picking up an item) , I want them to walk into the room again .

What is the best way to handle these scripted events ?
For example, I guess I can store hardcode the animation in a datafile , like : move to a, play sprite animation aa, move to b etc. and then play them as needed. But what I’m not sure with that method is how to overlap different scripted actions.

So is there a better method ?
Sorry this is a bit of a broad question

thanks!

It really depends on what you exactly want to do. Scripted events and cutscenes are different things.
If you want to do a scripted event, OnTriggerEnter2D is your friend, script your code and call it from there.

If you want to create a cutscene in the game (not a video), I suggest you to use Unity’s own animation tool. Create a gameobject, attach it a script, and open animation tool. Choose the timeline and add Animation Event there, just to call your function at that specific point.

My game is a 3D horror game, and all cutscenes are in game. I use animation tool with a script to call functions to create effect the way I want with a timeline instead of events, delegates and enumerators.

Hope that helps.