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

Can someone help me understand how to go about setting up a project like this in Unreal using blueprints? I understand the concepts of the video but some things like implementing sphere tracing in this specific way are new to me. Any pointers would be very helpful.

Batman Arkham’s Freeflow Combat | Mix and Jam

Hey @unvoicedbee!

So could you be a little bit more specific in your question? You can always ask additional things later. As far as the sphere tracing thing, I can supply the documentation on it, but without any additional info I’m not really sure where to go from there.

1 Like

I’m trying to recreate the video’s entire system from scratch in Unreal. So far I’m able to understand it is calculating the direction of the trace based on the camera and input direction, I’m guessing on a tick? But for starters I’m not sure how to set up the trace correctly to detect an enemy based on on the calculated information.

OK! Soooo looking at the video:

This:

In blueprint (I think, I’m freehanding a bit):

Put this on your Third Person Character, and it will get your directional input, give a distance of about 10 Meters with a circle about .5 Meters wide :slight_smile:

Give that a shot and see if it fits your qualifications!

1 Like

Great that works perfectly thank you so much! :smile: So the next step would be moving and rotating the player to the hit pawn once an attack input is pressed. Could this be done with a Move Component To node?

Also to be easier on the player I’m guessing it selects the pawn closest to the player in the direction of the trace. Maybe it uses a different kind of trace all together using the same start and end information?

It actually looks like the sphere trace will only grab the first one if two are lined up so that works! I increased the radius of the trace so it’s not easy to miss a pawn as well.

Awesome! Yeah, you don’t want to use Move Component, components are PIECES of your Actor. You will want to move your entire character.

So you’ll want to right click and break your Out Hit, and grab Hit Actor, and set it as a variable.

image

Then you’ll make an event (you’ll want to do it using the Project Settings> Input but for this example I’m going to use enter) because we don’t want all of this on tick, ONLY the target grab.

Something like this. You’ll use a timeline for this.

Inside the timeline(2xClick): 2s duration, one key at 0.00 time and value, one key at 2s time and 1.0 value.

1 Like

Gotcha, makes sense we want to move the whole player and not just the capsule. I’ve got is set up like yours - it’s working as intended except moving the player exactly to the hit actor’s location is causing a collision bug. Perhaps we need some sort of offset so they’re not overlapping?

Also, @Mind-Brain, I really appreciate you helping me out with this. It’s something I’ve been trying to figure out for awhile and keep getting stuck so having your guidance means a lot, thanks for taking the time to figure this out with me!

Of course @unvoicedbee !! It’s what I’m here for after all!

So we’re going to try this. We’re going to use a different location, where the initial HIT happens, so the edge of the sphere would be hitting the enemy.

Changing the Radius of the circle would create your stop distance, which should be your Character’s Capsule radius plus your enemy’s Capsule radius plus maybe 10+ more. You’ll have to find that out and input it.

Next you’ll set the Out Hit Impact as a V3 variable.
image

Now let’s set up a branch to prevent double-attacking and turn off the target look during the attack! Start by making a bool variable, I called mine IsAttacking. Make sure the variable is set to “False” by default. Then we’ll set it up like this (I circled new/changes in green)

And then put us a little check on tick to save some processing power.

Give that stuff a shot and let me know how it goes! Don’t forget to set the sphere trace radius! (PlayerRadius + enemyCapsuleRadius + 10, your own math no nodes)

Definitely working better, I added it up and the radius should be 80, but there’s still some collision issues even increasing it more than that and the player can get stuck inside the enemy’s capsule component.

@unvoicedbee did you try 120+? This is really a workaround, I’m having a hard time trying to get a point on the vector line that would work in all directions around the enemy without making the character an AI.

I know how to do it I’m just having a hard time accessing that part of my brain at the moment.

Yes, tried all the way up to 150. Maybe if we offset the impact point somehow?
And no worries it’ll probably take time to figure this thing out in general and that’s okay haha
The video builds some simple enemy AI anyways it looks like, would working with an AI be easier?

I switched it to the out hit location instead of impact point and that fixed the collision error :smiley:

@unvoicedbee Awesome! I guess I just had them switched in the old brain-jar.

What I meant was “without making the player function as an AI to use the MoveTo function”, you’ll still need to make the enemies’ AI controller and either hard-code their behavior or use Behavior Trees/Blackboard. For these simple guys I’d suggest coding with Blueprints (hard-coding them).

But first, coding the enemy taking damage (use the variable we saved of Hit Actor), then animations! You’ll want to look up a tutorial for importing if they aren’t UE5-ready (mixamo is not, some store assets are not).

That’s what I was thinking for the AI too!
Animating the attack should use a montage before the timeline correct? I’ll set up a basic health system.
Next issue I’m running into is the players rotation and location are stuck until the timeline finishes, takes the flow out of the free flow haha - any way we can fix this?

2022-10-26 21-00-50.mkv (22.1 MB)

I think that must be an issue with the timeline. Can you double-click it and show me what’s going on in there?

You were right! I had the values of the second key reversed :sweat_smile:
It fixed the jitter but I still can’t move until the timeline is done

2022-10-26 21-22-48.mkv (14.3 MB)

Okay! So! We need to set the length of the timeline to roughly the length of your animations. You can set the length to 1 second (make sure to move the Key) and you’ll notice the difference.

Also you can put an AnimNotify in your AnimMontage to set IsAttacking to false at a point you decide. Then you’ll go to the Animation BP’s Event graph to do what you need. Use TryGetOwner to get the player, then drag off of that to do SetIsAttacking :slight_smile: