Week 4: The Action Begins
March 22, 2024
Welcome back to my Senior Project Themedior! Today, I will be reporting on the progress I have made in my operation of adding movement to our main character, Cynefin. Starting off with a Q&A and an explanation of how Unity imports PSB files and finally to my struggles with the animator and scripting movement.
Q&A
Q: “Which parts of the process are being accomplished in Live2D and which parts happen in Unity?”
A: For the game, we plan to include some cutscenes which will be animated in Live2D Cubism but the actual game sprite of the main character (which I included in last week’s post), will be animated in Unity.
Q: “Are the parts separate or integrated together?”
A: As mentioned in my previous post, I divided the sprite for our main character, Cynefin into different parts. Each of these parts are separated onto a different layer and sorted into folders based on their relation (e.g. one folder may contain all the parts of the head (eyes, hair, etc.) and another folder may contain the right leg (right lower leg and right upper leg)). These layers are then exported as a PSD file for Live2D Cubism or a PSB file for Unity. As PSB/PSD files, these layers/folders don’t have any relation to each other. But once imported into Live2D Cubism or Unity and rigged, the layers are linked to bones, deformers, and skeletons which integrate them together. I will be talking more about how the layers work in Unity in this post, so look out for that!
PSD Importer
Something I didn’t have time to mention in my previous post was how to import the multiple layers. In order to properly import our main character, I used a built-in importer called, “2D PSD Importer.” Unlike the name suggests, the importer actually takes PSB files by default, although it can also take PSD files. This importer allows me to preserve the layers in my PSB file and generates each layer as a separate sprite rather than merging them all into one. So technically, the main character sprite is composed of many other sprites under a parent game object.
Animation and Animator
For any kind of animation you create, keyframes are an essential step to map out motion and for ensuring smooth movements. For each animation, I created a new animation file and set up the frames like this. Each dot on the timeline is an individual keyframe and each row is used for moving a different bone/rotation.
(These are the keyframes for just the running animation.)
Once the keyframes are added, I finetune the movements to make sure they are smooth and loop properly. Finally, once I finish setting up all of the animation files, I end up with these animations.
walking | jumping | running | shooting |
However, this is just the beginning of getting Cynefin to complete actions. After creating the animation files, I set up the animator, which controls triggers and transitions for the motion. In the animator, each animation is treated like a node and you start off with the “entry” and “any state” nodes. The “entry” node dictates which animation plays by default and the “any state” mode lets you set an animation that can be transitioned to at any state.
After adding each animation as a node to the animator, I link them all together based on desired transitions and set up conditions for transitions between the animation nodes. Initially, I had some trouble getting the animations to transition properly. I was able to fix this after tinkering with the exit time of the transitions.
In the animator, another option you have is to add layers. This allows me to add blinking to the character and overlay attack animations no matter which animation is currently being played for the character.
Scripting Movement
The next step to getting these actions to actually work in the game is to create a character controller script. Within this script, I declared Input Actions, which allow me to detect what keys are being pressed, the animator, for playing the animations, and the rigidbody, which I will be using to move the character.
For changing the animation, direction, and speed of the character, I used the update class, which runs once per frame.
However, for motion, I used the FixedUpdate function, which is in sync with the physics engine and won’t cause varying physical effects based on engine load.
And finally our character is ready for action! (note: I haven’t added physics yet, so the jump animation doesn’t actually lift him off the ground).
Continuing On
And that is basically all I have accomplished this week. I hope you enjoyed the gifs of our main character moving around. For the next step in this operation, I will be working on the projectile system as well as developing the dialogue system. See you next time.
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.
Cindy L. says
The animations look great so far! The overlay to add blinking and attacks is also a smart move, I wasn’t aware that was an option. I’m looking forwards to when you actually implement physics, and we can see your main character actually jumping.
Maggie L. says
I like the visuals you add! They make it a lot easier to understand the parts of the process.
When you say that the animator treats animations as a node, does “animations” refer to parts of a whole animation, or separate complete animations that transition into each other?
Also, thank you for the Q&A! I’m super excited to see the final animations!
Harish Senthilkumar says
Your explanation of the animations is really good! I learned a lot about how animations are really done.
My only question is are PSD and PSB files just file types for animations specifically?
I really like how you answered all your Q&A questions as well! Keep up the good work!
Isabelle E. says
I love the spaghetti code you have haha, that animation tree looks awful (in a good way). Thank you for your explanation about animation! I’m inspired to try using Live2D on my personal artworks now!