3rd person Combat "soft target" system, move to enemy on attack?

Hi!

I am fiddling with a 3rd person A-RPG, after some Kena Bridge of sprits inspiration!

I have made a Combat system that moves the players towards the enemy if you attack within a specific range (say 100-550 units), its not triggered if your target is in melee range already.

Right now I use a Dot-system to find which enemy is closest “in front” of where the player is aiming with the camera. Highest Dot-value sets the enemy as target. If an enemy is already in melee range, that enemy have increased “Dot Score” to lower the chance you just jump around between enemies.

My issue is that i am not pleased with how the character is moved towards the enemy. I use a timeline, find enemy target position and place my character just outside their capsule. But it just feels wonky. I am very happy with the “soft targeting”-system but this feels… wrong…

Its quite buggy when it comes to hight difference etc. And if the enemy moves towards me we can get stuck in each other.

An idea I have is to spawn an invisible square, on the ground, moving with the enemy and always making sure you land on a valid spot. But that seems a bit excessive…

Anyone done anything like this before and have some pointers? Or know of a guide/tutorial or even marketplace asset that have this kind of system for inspiration?

Could you let us see it in action w/ the blueprints?


Blueprint before this triggers just calculate the dotproduct + range to enemy to set a suitable target. If no suitable target is found, the code launches the character forward a bit. This is to simulate root motion, I use in place animations since I will try to make this co-op / multiplayer.

When a target is found I use the timeline to move the character towards the enemy to get into melee range. The placeholder animation isn’t the best, but it just feels clonky and not as smooth as I’d want to.

Also, the height thing is an issue. I tried to just limit it to “If Z vs Z is too different, dont move to enemy” but that would ruin any uphill landscaping etc.

The AI had the most basic piece of movement code ever, so I just tweaked it a bit and it seems like I don’t get stuck anymore atleast. But it’ll be an issue with bigger enemies with bigger capsules… Is there a way maybe to just find how far the enemy collision capsule reaches and have it dynamicly change to solve this?

I just loved the smooth feeling they managed to get in Kena.

Awesome!

You can try having the characters rotation independent from the camera so that he constantly faces the target as he fights. this allows so that you can use the camera to search for new targets.

If I remember correctly, games like Ghost of Tsushima and FF7R use soft target and you can attack a target by inputing the direction in the controller (or camera looks at target and W). Don’t remember if Kena is like that, think it is.

You could try a trace using the hit location as a reference.

Edit: for example…
AttackToLoc

This one is tricky. On the initial attack you could trace if you have line of sight, then trace along the path checking if there is ground towards the target… I’m sure there are better solutions out there.

Yeah. my original idea was to have the camera fixed. Since I kind of prefer that, but I can see how it would work a lot better with that way. This way you could, as you say, have both “keep attacking enemy in front of player” and with a button press or while moving forward “attack enemy camera aims on”. Could actually be better.

You could try a trace using the hit location as a reference.

That is a great idea, thanks!

This one is tricky. On the initial attack you could trace if you have line of sight, then trace along the path checking if there is ground towards the target… I’m sure there are better solutions out there.

I have some ideas but I want a simple one. I was thinking about making invisible boxes every 25 unit from player to target, and make a curved spline between them. If the spline is too curved, it fails. I’ll wait a bit with this one.

Thanks for the help, I’ll see where it takes me :slight_smile:

Got a solution I’m quite happy with, thanks for the ideas. Still need to validate ground on the distance attack, but overall it’s a lot smoother and the camera actually made a lot of difference. It’s much better this way.

I ended up checking for AI pathing with “Find Path To Actor Synchronously”. My target checks if there’s a valid path between the enemy target pawn and player pawn, if there’s no valid path or if it’s too long (like with the stairs) it fails and no distance attack towards the enemy.

Thanks :slight_smile:

1 Like