Help translating Unity code into Unreal Blueprints for Free Flow Combat System

The anim notify was causing some weird snapping issues so I just changed the length of the timeline and that looks good!
Can you explain 2:45-3:08 in the video to me? I understand he’s using a notify to tell the enemy which reaction animation to play and when, but I don’t understand how that is being communicated to the enemy actor.

Also, it’s getting late here - if ya don’t hear from me I promise I’ll get back to you tomorrow. Very excited to keep working on this :smile:

Batman Arkham’s Freeflow Combat | Mix and Jam

Ok first let’s start out by creating a custom event on the Character BP.

image
We’ll call it Damage Enemy.

Next grab your TargetEnemy and drag off of it to make an ApplyDamage node. Give the damage a value of 1 (this won’t matter as long as there’s a value of some kind).

image

Next open your EnemyBP and OnBeginPlay, place a BindEventToOnTakeAnyDamage, then drag off of the red square to add a customEvent, let’s call it Damaged. Then do a PlayAnimMontage Node from there

Now on your PlayerCharacter’s Animation BP, you right click and type AnimNotify. If you’ve put in a notify for your hit in your attack animation, it should be there.

Use TryGetPawnOwner to grab your owner, drag off that to cast to your player blueprint. Right click the cast to convert it to a pure cast, then drag off of that and get a node called “Event DamageEnemy”


Make sure this is on the Animation Blueprint!

And that should be good :slight_smile:

1 Like

Thank you that makes sense out of it! I added the hit reactions and an example impact effect.

Next would be the enemy movement. I can set the enemy to face the player on event tick (or maybe there’s a more performant way to do this I’m unaware of?) - but I’m lost on how to make the enemy circle the player.

Hey @unvoicedbee!

Circular strafing is actually something I’ve really had a hard time with in UE5. In other programs it can be pretty straightforward, but in UE5… really not sure how to go about it.

Try posting another topic with that as the title and see if you get any bites! :slight_smile:

1 Like

I found a youtube tutorial for that so I’ll give you an update when I’m ready for the next steps :smile:

To backtrack a little, I had some thoughts I wanted to bounce off you.
Would it be better to use motion warping to move the character to the enemy AI? My thought was in a scenario where you’re hitting one opponent multiple times looks disconnected the way we have it set up. Motion warping would keep them together and account for the distance?
Secondly, if nothing comes back on the initial trace it’ll move you back to the last hit enemy - not a big deal if you’re already near him but would be frustrating to control if you barely miss the enemy you’re aiming for and get snapped all the way back to the last hit enemy. Is there a way we can get the closest actor to the trace even if it doesn’t successfully hit? Something that works as a failsafe so we’re always being moved to the intended target.

@unvoicedbee I wouldn’t use warping for this, if it’s similar to the Arkham series, the warp won’t mean anything since you’ll be in the air or doing a leap of some sort vs running faster.

What would be the best option is probably a select where we get the distance to the enemy and if it’s short we do a shorter timeline with a shorter animations. Have like a short, medium, long distance select with appropriate reactions.

As far as nothing coming back on the original trace, use an “IsValid” node to make sure there is something set to EnemyActor before executing the attack code, so right after the button input. On true, execute code, on false, do nothing. Otherwise it’ll go to world 0,0,0.

I’m not sure I understand what you mean otherwise in your “secondly”. What would the intended functionality be? Try to quantify it exactly :slight_smile:

1 Like

Gotcha, perhaps for a free flow combat game like Mad Max motion warping would be more appropriate since it’s grounded? But for something more aerial like Arkham a select sounds more appropriate - how would I go about setting that up?

IsValid worked! I’ve attached an example of the other issue, even if the player input is pointed towards a new enemy, if there is no hit it will go back to the previous enemy. Perhaps in games like Arkham they are just finding the nearest enemy in an input direction instead of using a trace? Or maybe a combination of both?

Okay, so this is our starting point:

Now between the Attacking bool and Timeline we’re going to put a switch on Int.

image

Next, make variables for LongDistance and MediumDistance as Floats, and AttackDistanceInt as Integer. What this will do is check:
is it far?
is it close but not too close?
if both of these are no, it must be close. So 2 for long, 1 for medium, 0 for close distance.

And then using a sequence node, we can move on now that we have that information, and decide which code to execute :slight_smile:

1 Like

Awesome that works great! I’m learning lots from you thanks :smile:

So what about the next issue with trace? Did I explain that in a way that made sense haha?

Hey @unvoicedbee, I think i get what you’re asking with the trace, so let me explain a little clearer…

So with the goal being collection of information, such as getting the closest enemy in a given direction, trace is the method. These two things are not separate, you use one to achieve the other. Does that make sense?

1 Like

I think so, would we need to add logic to detect the nearest enemy in the trace direction then? That way they work together to move you to the correct enemy even if the trace misses?

Well you see, even if the trace passes through multiple, it returns the FIRST blocking hit. So the closest thing. I know there are times in Arkham City where if you’re fighting one enemy it will grab the nearest one. MAYBE… We could do a big sphere trace directly on your player IF and only IF there is no registered enemy from the line trace. You’d drag off of your HitActor after your first sphere trace, do as normal on the VALID, and on NOT VALID drag down to a second sphere trace where both your start and end are on character, then make that radius pretty large. From there plug back into your other code :slight_smile:

1 Like

I think I understand, so if the initial trace comes back false we’d do a second trace around our character to get the nearest enemy. Would this second trace also work with the input direction? Lets say in the second trace multiple enemies are hit, but the closest one is in the opposite direction of our input - would it move us in the input direction or the closest enemy?

Hey again @unvoicedbee! So the movement itself is based 0% on what direction the input is pushed. Input is what grabs the target, then the button press says “go to: in front of my target’s face.” The second trace would not care about input direction, and you could use an “Array: Add” node to set all close targets to an array, ForEach get their distance, and then on complete, compare their distances with each other and set target to the one with the lowest distance (all things we have learned, right?) :slight_smile:

Personally I’d just leave it and have it choose the target automatically, if it doesn’t throw errors. I think it might make it seem like more instinctual behavior with multiple baddies very close by.

1 Like

Okay that makes sense, thank you! I think I can figure out the rest of it from here - parrying shouldn’t be the difficult and I’m sure there are tutorials for the finisher camera. Thank you so much for all your help!

Is it okay if I tag you in another post? I’ve been asking around the forums with no luck on another issue I’m having. Seems like there’s a very easy straightforward solution that I’m missing haha

@unvoicedbee go ahead and do so! I’d be glad to help. :slight_smile:

1 Like

Thank you!!

AI strafing video and solution to a possible problem.

2 Likes

I’m not sure how to directly message someone on here, but I’m trying to follow the implementation on this very detailed post, but my use case is different. I am trying to follow a similar example as it is definitely Free Flow combat, but it involves a character who runs fast like this: https://www.youtube.com/watch?v=k5uhw7eNvUw which has some interesting mechanics I am trying to rebuild. I have reached out to the creator of the video, but no luck so far. Was wondering if you or someone you know can help me with this? Thanks

Hey @CoffeeAddictGames!

Let’s make a new topic for that- it looks like there are some similarities but overall it’s going to be about 80% different, I think. That being said there was somewhat of a reference video they were following that was a big help in bridging the gap whereas this one you’ve posted is somewhat unique, let’s try to get the larger community to bite as well as myself! Also try to be specific about the things you’re trying to use- this isn’t just punch and kick, it looks like there are specific extra abilities akin to Sony’s recent Spider-man titles for Playstation.

1 Like