Fighting Game - How to make fighters walk backward when facing other player?

You know how in a fighting game when you jump over the other player the players immediately turn to face each other? I was able to figure out that element, you can read that thread here.

Now comes the next step…while they are facing that player if they press away they walk backwards.

You can watch on this video the effect of just a plain ole 2d blend space set up as usual.

The forward walk looks correct but the backwards walk has the moon walking effect. I set up a clone of the blend space where I used reversed animations for backward walking and running. If I hook this up, then the backwards walk is right, but the forward is wrong. :frowning:

Any ideas? Thanks!

bump

I need to be able to swap these two paths based on which way player is facing. I tried blend by bool but am not seeing it work as needed.

About what you said, its been tweaked so it instantly turns left and right. And yes, X is nol being used.

Hi @usa423!

If you are switching between more than two states, using blend poses by int or blend poses by enum may work better for you. Here is a good Non-Epic affiliated video that shows how to set that up:

Blend Poses By - AnimGraph in Unreal Engine 5 Tutorial!

I hope the above solution is what you are looking for!

Hello!

Thanks for the link. I have learned more about the blend pose by int or enum.

bump bump

What if I used Montages to accomplish essentially the same thing as the animation bp, yet more less bypass the animation BP through a slot??? Then I could do everything from the third person character bp.

bump bump

Hi @usa423!

That might be possible but I am unsure if that will solve your issue that there is no negative speed?

A couple more questions:

  • How does your overall anim graph look?
  • Have you tried having a different state for walking backwards instead?
  • How are you determining the direction the player is facing? Is that something that can be used as a conditional?
  • Have you tried calculating the dot product of the actor to check if the character is moving forward or backwards,? You can use that as your conditional for switching between the forward and backward states. Here is a thread with more information on that:

Unreal Engine Forums: How to tell if an actor is moving backwards or forwards

Any additional information you can provide will be a big help in solving your problem!

Yeah, I may have to try the more traditional animation method.

The other day I saw a thread here that gave me an idea, it had the state machines / states laid out like a pyramid. So I thought I might could get this to work for this concept.

About the only thing solid seems to be the jump and the crouch.

That is what I’m trying here…taking a typical run animation set backwards to simulate backwards running. I could most likely get a better backwards running animation from Maximo but for testing purposes this should suffice.

The idea then is to trigger the backwards animation exactly when needed. For example…facing Right? then pressing left = backwards walk…facing left? then pressing right = backwards walk.

For checking the pressing of left or right just have 2 bools set in the character bp.

I have tried to use two booleans (facing left? facing right?) placed directly after the SetActorRotation nodes that turn the player to always face other player, I imagine that would work but it may not be working right.

I have not, actually have not used the dot product thing yet to my knowledge.

To determine if moving left or right, I hooked the capsule component to a GetComponentVelocity node fed to a print string.

This video shows it more in real time.

(that strange mirror effect of the other player must be because something is not an instanced copy)

Will be studying that link, thank you.

So, I thought that I could do something in a transitional rule to get what I needed. But so far I haven’t got it.

I think I did the ABP event graph correct to gain access to my character BP booleans but maybe I didn’t?

Going back to the state machine…I will show you what I have just on the backwards path from idle.

I don’t understand why this does not work… I’m checking three things plugged into an AND boolean.

  1. Is the Y greater than 0? (a positive number)
  2. Is Facing right?
  3. Is pressing right?

If all three of those conditions are true, why is it not working?

Hi @usa423!

So far I can see two places that could cause errors with your setup:

I can see that there would be that the variables set to true, but nothing to set them false here, so that would cause issues if you are checking for one to be false.

Your logic for moving backwards should be the opposite of the direction you are facing. So if facing right, you should be moving left to go backwards.

I hope this gets you closer to solving your problem!

Ahh, yeah I forgot about that.

Yeah its a bit confusing, and again thx for all the help. I hooked a print string up to a get world rotation of the capsule component in the side scroller character BP. It showed me that when the character is facing right it is actually -90, and when it is facing left it is regular 90.


Here is what I have so far.

When facing right it seems almost correct, the only thing out of place was that wonky jump peddle…I assume somewhere an is falling node has to be factored in to stop that.

Feel free to tell me if anything is way out of place you see here.

Here I tried to show my transitions with those states.

So what you told me makes sense…no way to show that variable false, that must be why I’m having trouble once the character flips the other way.

— forgot to mention…where things are zero in the “greater than”," less than" nodes, has been changed to 1 (backwards) and -1 (forwards).

I just got it! (well just need to fix the Luigi jump situation).

Idle to backwards

idle to forwards

Hey @usa423!

I believe I see your problem with your “Luigi Jump”. Your forward and backward states can not directly enter your jump state, forcing you to go to idle before you can enter the jump animations.

Correcting the animation so those states can be transitioned to directly should solve your issue.

I hope the above solution works for you!

Thanks, what I did was make a path from the forwards and backwards to jump start. It alleviated the problem.

The only other thing I did was turned up the acceleration to 100K and now its more snappier.

You can watch that effect and the added states in this video below.

Once again, thanks for all your advice!