2D Animation State Machine Problems

So I just picked up Unreal Engine and have been practicing over the last few days trying to learn new things. Right now I’m messing around with a 2D sprite in a 3D environment similar to Octopath Traveler and trying to get my 2D animation state machine working correctly but I’m having issues with my idle animations.

Run Walk Branches.pngRun Walk Branches.png

Prior to this, I watched the official tutorial on the website for creating a state machine with basic animations. With that I was able to get the sprinting and walking animations working properly in all four directions but I’m having trouble how to design my idle animation. Is there a specific condition that I could feed into my branches to have the idle animation remain facing the last direction the character was traveling.

Also since I’m very new to this, I was wondering if my way would suffice or is there a more efficient design that will be better performance wise with the ability to easily add more animations later on (jumping, falling, climbing etc.)

In your example:
Replace the Branch nodes with a switch node and plug in your “Animation State” variable, and then connect the outputs to your desired idles. Like so:


https://forums.unrealengine.com/core/image/gif;base64

You can also multi-connect walk and runs to the same idle, I just didn’t add them in my quick example…

Anyway, if you’re serious about making your project, and open to 3rd party help, I highly recommend PaperZD.
You already have quite a tree of branches, and it will only get more convoluted as you add more animations. It made animation work on my own 2D game so much easier, and I can do things that would be either impossible or nearly so with only branches and switches.

I appreciate the heads up on the PaperZD plugin and have had my eyes on it while working on this project. Since I’m completely new to unreal engine I’m not trying to spend money on plugins yet but more so getting practice with blueprint system but I realized there is not really much support for the paper2D on the engine at the moment.

Do you mean something along this? Even if I replace the idle branch nodes with above I’m still having problems. First my sprite will not appear on the screen until it receives a movement input and it also still remains in the last walking or running animation after I stop input. I attached a video showing the problems I am having.

Yeah, Paper2D has been largely abandoned by Epic, so what’s there is likely what it will be for the foreseeable future. That’s why some other devs added their own plugins to fill the void and add some much needed functionality.
I was pretty much in the same boat a few months ago - learning Unreal while doing a 2D game, not looking to spend money, and I was lucky to see that plugin on sale for 15 bucks.
And I’m glad I did - as I mentioned, I can do things I could never dream of doing with stock Unreal tools, and it allowed me to focus on learning other blueprint logic and not be bogged down by animation. I can only say - it’s gonna be tricky now to do all that in branches, but once you start adding action animations or think about adding transitions, the issues will grow exponentially.
Plus, the PaperZD thing works very similar to 3D state machines (at least the anim graph), so you could start learning that logic for when you want to “graduate” to a 3D game in the future.

Anyway…your call, not trying to talk you into anything.

Back to your problem:

  1. If the sprite doesn’t appear until you press a movement key, it’s likely your “Animation State” enum doesn’t have a default value and/or your character doesn’t have a flipbook set.
    So set your paperSprite component and give the enum a value, and to be sure, you can also add “on Begin Play” > set Animation State: Idle Right and "set Flipbook: IdleRight (or whatever Idle you want).

  2. If the animation doesn’t change when you stop moving, it means that there is no event associated with stopped movement.
    If your Anim State Machine runs on tick , you should be able to just hook up the Idle switch to the false output of the “is moving” branch check.
    Same applies if you’re using an InputAxis event (I believe they still fire even if input is zero).
    If you’re using action key for your movement you’d need to fire your animation state machine “on released” as well.

It’s likely just one logical dead end somewhere, but really hard to say from afar.