Animation based on Direction (4.27.2)

Hiya. I’m working on learning how to make a 2.5D platformer, and I want to play certain animations based on the direction the player is facing (since certain animations may be obstructed from view based on said directions).

So like, one animation when facing right, then the the mirrored version when facing left. I assumed I could use a branch node to tell it to play an Animation Montage if facing Left was true, then play the mirrored version on a false result.

I just can’t wrap my head around getting the direction on a 2D plane. Is that World Rotation value? Local rotation value? Forward Vector based on the world direction? I’ve tried finding answers everywhere.

Please help!

The animation montage will automatically chosse the correct animation based on anything you like, that’s the point of this part of the engine.

As you say, you can base it on character facing direction.

The character direction on a 2D plane is just the same as 3D, except you don’t use one axis at all.

I’m assuming you’d want to cut out Z, but it really depends how your character is set up. Once you have that established, you can just use your forward vector ( without Z ), to drive the montage.

The thing I’m running into in my blueprint is how to differentiate the direction regardless of the forward vector. I’m doing a ‘success’ animation (fist pump), but when facing left, the arm is obstructed by the body. So I wanted the character to use the other arm (thus the mirrored animation). I just don’t know how to set that up.

Is there a simple way to tell ‘when forward vector is facing screen space left, play this montage, then when facing screen space right, play the mirrored version’?

When the character is facing right, the forward vector is in line with the X axis. When the character is facing left, the forward vector is pointing at the origin.

You can find the angle between vectors with arc cos of dot product

( they need to be normalized ). One of them would be set to the X axis:

As far as the mirror animation goes, not sure about that, sorry.