Getting the 2D directionality of an actor?

Hey guys, I’m trying to get my character to play a different animation when he is facing to the left (instead of just playing the 180 degree rotated flipbook.) Is there a way I can either pull a variable from the character, or set up a state that tracks if he’s facing to the left or right? I can get it to kind of work by tracking the input Axis of the thumbstick and comparing the float (<0 means I’m going left, >0 means I’m going right.) Is there a better way to do it?

You shouldn’t use the input Axis, what you need is the motion velocity using “Get Velocity” from your character.
Then it returns a 3D vector that you simply break and get the X component.
If X<0 is going Left.
if X>0 is going Right.
if X=0 there is no horizontal motion.

Awesome man! thank you for the response, I’m definitely still learning :slight_smile: ill try it asap. So this will be for a Boolean variable indicating which direction the character is facing? (Because the X vector above 0 would indicate that he’s facing to the left?)

Get the boolean red pin to a branch node if X>0 true then is facing Right.
I think you should check this in your Event Tick to know all time where your character is facing.
One last advice: Only change the animation when the direction changes, be careful not to call again the Set Sprite or Flipbook for every tick.

After you test the solution and being sure it works, if you like please share what you did here and mark the answer as correct to help others :wink:

Absolutely! I will. Thank you again, you’ll be seeing a ton of me in the future :slight_smile:

Worked exactly as it needed to. Now i just have to tweak my blueprint until I can get idle to sit correctly.

I was thinking that I missed a last advice. Instead of <0 and >0 maybe is better to check if velocity is near to 0, like x<-0.1 left and x>0.1 right, because in very slow movement is better to witch to idle animation. Idle between -0.1 to 0.1 .

Im having a problem getting the animation to idle after moving in a given direction. It immeadatly defaults to the left Idle, and i see why. its looking for Isfacingright to be true, but cannot because its looking for a velocity that cant exist without movement right? So the branch snaps to false, and forces the idle animation to be on the left. Do I have to create some kind of state that tracks if its facing left or right?

this should do the trick , only sets “IsFacingRight” when velocity != 0

Perfect! it now functions exactly as it should :slight_smile: you guys kick ■■■!