- Home /
"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!
I don't know for sure what you mean by hard code the animation in a data file. I'd script movement first, methods for walking from point a to point b. Then do the dialog, show chat bubble, display text, move through paragraphs. Once you get those working, consider a director script that handles the story/progression of the game, with series of events, like your saying, character a walk to b from a, dialog 1 plays, character b dialog 1 responds... So on and so forth. As far as animation itself, use an animation controller I think it's called, create a state machine for any possible animations, call at the appropriate time from the controller you script. There's my thoughts. Good luck!
yeah that's what I was trying to say with hardcoded, store the animation data somewhere and play it just like you described. Thank you , this does help!
Answer by Tanshaydar · Nov 15, 2014 at 09:30 PM
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.
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How to make an animation play after releasing key? 1 Answer
Animation not at correct position W/Video 0 Answers
Animated Overlay Armor Sprite 1 Answer
Animator State Freezing 0 Answers