Main Content

How do I add animations to these assets? I purchased both of them the other day, I love everything so far, I'm off to a great start already with building a game that would work around them, added my own custom skins, tweaked some animations, etc... but I'm having trouble figuring out how to add controls for brand new animations.

I added a crouch animation inside Spine, exported the character to Unity, including the new animation, but I'm having a hard time wrapping my head around how to modify the HitmanController.cs to include the new "Crouch" animation that I added. I basically just want to have the character crouch when I pressed down on the left joystick on an XBOX controller.

I tried adding Crouch to enum ActionState, and then added the entry in UpdateAnim(), so now if "state = ActionState.CROUCH" then ideally, it would play the crouch animation. I then tried to add the controls in the Input() section, but that just causes the character to freeze in place.

if (moveStick.y < -0.25f) {state = ActionState.CROUCH;}

So now when I press down on the left thumbstick, it just freezes in the middle of whatever animation I'm in, and the character slides to a stop. The crouch animation isn't working at all, and then the character just freezes in place, and I can't move again without resetting the game.

Is there an easy way to add new animations to these characters? I don't really want to break any of the current controls, because I like the way everything controls so far, but I'm hoping to find an easy way to do something like...

"If I use one of my custom control entries, then it'll play my custom animations, otherwise, handle everything as it normally would." I feel like I'm stuck in a bowl of spaghetti trying to figure out where the right place to set my custom animations would be.

11 months ago

Etmos

Posts: 6

Mitch

Search for "//ground logic"

editAh fine, here's a tutorial.

---

Here.

11 months ago

Mitch

Posts: 970

Etmos

Thank you very much! That's exactly what I was looking for. I figured out a way to do it, but my solution wasn't quite as clean as yours, and hearing you break down the logic behind your code will definitely help me understand how to approach it in the future when I want to tweak some more things. Good tutorial, much appreciated!

And I apoligize about the spaghetti comment, ha. I was mostly just describing how my brain was trying to work it's way through the code, without understanding the overall structure for where things are located. It all makes perfect sense now though. Want to add "ground stuff", look for the ground logic, jump stuff, jump logic, etc... I was mostly just looking for "controller logic" and since it seemed like the controls were mixed in everywhere, I felt lost.

My solution was to just add code to override everything in Update() when I press down, and it works, but it's not nearly as cohesive as what you already have laid out.

Great assets, keep up the good work, and I really appreciate you taking the time to make the tutorial.