[Game of Purpose] Day 18 - making flying animations
Tags: gamedev
Published: 2024-06-06 00:12:01

Today I followed up a [second part of a flying tutorial](https://www.youtube.com/watch?v=XOdR5DRsiz0), where I added animations.

I have to say that the tutorial was too fast. The author just told what to click and where without even explaining what was going on. So let me be clear what happened:

1. First I imported custom Akai character model from [mixamo.com](https://www.mixamo.com).
2. Then I imported Floating and Flying animations also from [mixamo.com](https://www.mixamo.com).
3. Then I created **IK Rig** for both Manny (my current character) and Akai (the imported one), where I used their skeletal meshes to mark body parts. I selected elements responsible for moving Spine, Head, Left Arm, Ritht Arm, Left Leg and Right Leg and named them accordingly. This was important I think, because the internal structure looks different between these 2 models and doing this step we just mark common parts. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpbdrq6u2qezifzi391j.png)
4. Animations I downloaded are strictly tied to a skeleton of Akai character, because they are from the same vendor (Or not??? I'm not sure). To make sure they work on Manny I created **IK Retargeter**. Inside I selected IK Rig for Akai as a source and IK Rig for Manny as a target. This way we can map that Head from one rig maps to a head to another rig. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tcqsmk9a84q85ixxx2l.png)
5. Inside that **IK Retargeter** I exported Flying and Floating animations to a dedicated files. These animations work with Manny skeleton, whereas the original ones work with only Akai skeleton. ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2n5oc11xxegcvo9iw62q.png)
6. Then I created **Blend Space 1d**, which creates a smooth transition between the 2 animations. Inside I created a variable `Speed`, which controls which animation to choose more. The closer to 0, the more it's Floating; the closer to 600, the more it's Flying. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mf5syuxdz5ywxung4o5l.png)
7. At last I needed to edit Animation Blueprint for Manny. First I needed to set up local variable `IsFlying`. Every animation tick it would be updated to a `MovementComponent.IsFlying`. I'm not sure why it was needed. We could use `MovementComponent.IsFlying` directly everywhere, but I guess it's so that this blueprint has a single source of truth and is more readable. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk1enk504kyjxvpwrly1.png)
Now this step I don't quite understand. I disconnected the red line and connected Locomotion directly to the Output Pose. Why?
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zqk4ql42yd3and2y0xy.png)
Then I edited Locomotion state machine with Flying state.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9dku0jbti8ekciqok67.png)
I updated all the transitions to and from the Flying state with a logic using the newly created `IsFlying` variable.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hy84j5jykl71p33n4oys.png)

Here is the final result:
{% embed https://youtu.be/PEaOfZol5y0 %}

There were some many files created that during the tutorial I didn't know why they were needed. Only during writing this post everything made sens after writing it down.