Making my own animation & cutscene system

This is the story of making my cutscene and animation system. I just thought it could be interesting so I made this post :slight_smile:

(btw I wasn’t sure what category to put this in)

Hello! I am making a rpg. One of the most important part did my game were the NPC’s. For simplicity, I will be calling the NPC’s, characters. Each character has their own dialogue, backstory, and mechanics. There is an other thing that these characters have, cutscenes.

For dialogue and cutscenes, I am using Dialogue Manager, a great plugin by Nathan hoad. I am using it as a “director”. Sending out commands and orders to other parts of the game during these cutscenes. During these cutscenes, I have the actual in-game character node, and if I need other characters for the cutscene, I need to spawn in fake versions of said characters, I will be calling them actors.

During a cutscene, I will define each actor required, and their spawn location. A transition effect is played, and they are spawned in. Great. One thing that the actual character and the actors have in common is that they play animations. Characters and actors are completely different, one has all the NPC logic, and the other is simply a for cutscenes. If I want a character to used in another’s characters cutscene as an actor I need their animations to be stored in a seperate file, so both access them. No big deal, I can use an AnimatedSprite2D’s SpriteFrames resource as its own file and load the actor’s SpriteFrames from a file path. Great! Now I have actors and characters playing their own animations. I have a cutscene system.

This is the part where I make the animation system. Quite obviously, to this point, I have need using the AnimatedSprite2D and their SpriteFrames. But I have one big issue with that. The difficulty of creating animations.

To create an animation, I have sprite sheets. I go the the SpriteFrames, make and name an animation. Go to “add sprite sheet”. Select the file from the window. Choose hframes and hframes. Select all frames in order. Set the FPS. Also, I must do a similar thing for my one-sprite animations even for just one image. This take far too long. I have a hundreds of characters. Each with over 10 animations. 1000 animations like this? No. I instantly decided to make my own system.

For so, I would be using a Sprite2D and it’s “frames” property. I created two resources, Library, for a characters ensemble of animations, and AnimationResource, for an individual animation. The library is needed so I can keep all the animations in a file, so I can reuse theme, as explained earlier.

The animation resource has three properties: time per frame, sprite sheet, and hframes + hframes. The animation resource has a dictionary with strong keys and animation resource values. Now I can create an animation by making a new key value pair, naming it, dragging in the png, selecting amount of frames, and time per frame. No opening new windows or panels, simply exported properties. Also the animation resources has another Dictionary[String, Texture2D] for single frame animations.

Added code to the actor and character to load animations into their Sprite2D’s and play them.

That’s it :slight_smile: thanks for reading.