# Directional Attack Inputs

Hello, this is my fourth question on a topic that I attempted myself and couldn’t find a solution to on my own. I searched in a number of different places and I couldn’t find anything. So I’m just going to ask and hopefully something helpful will happen. I’m attempting to make an action game in a similar vein to Devil May Cry and, probably the only thing left that I’m stuck on in terms of the prototype anyway is handling directional inputs. What I mean by that is having a character perform a different attack depending on whether the analog stick (because I’m designing the game around a PS4 controller) is pushed in a direction versus whether it’s in a neutral position. Specifically what I’m looking for is, if the analog stick is in neutral, it will perform a basic set combo. However, if the analog stick is pressed forward, the character will perform a forward rushing attack, and if the analog stick is pulled back, he will perform some type of launcher. The directions should be character relative, as in if the character is locked on to an enemy the direction the analog stick is pointing has to be the same way the character is facing for the forward input and in the direction of the back for the back input.

Thank you for your responses, whatever they may be.

Your character blueprint should have InputAxis nodes, you simply have to check, when the player executes the combo, if the value in that node is 0, greater than 0, or less than 0.

If you’ve got any further questions let me know

You want to create the input direction in world space first. You do this step most likley already when you move your character around relative to the camera’s rotation (yaw only)…

Afterwards I normalize that input direction so it has a vector length or size of 1. (However if you have normalized it but the size is 0, it means you are not giving any input).

If the size is not greater than 0, it means there is no direction input. Perform “Neutral Attack”.

If the size is greater than 0, we need to Dot Product our input direction and our character forward direction vectors.

If you’re new to dot product of two vectors then all you need to know is, it goes from (float) -1 where directions are opposite (like your input is backward from character forward), 0 where they are perpendicular, and 1 where the directions are the same (like your input is forward with the character). (also assuming both vectors are normalized to 1)

Example IE you press kinda foward but not perfectly you may get a value like 0.78 or kinda backward -0.13.

So finaly if DotProduct( player direction, input direction) >= 0 do a foward attack. Else we are backward so backward attack. Just note I used >= because the dot product could be 0 or perpedicular so we still want to do something.

Really just know how to use Dot Product to compare vectors and you’ll do great things!

The problem with this suggestion is that it assumes the direction you’re facing is always along that axis. Remember, the controls have to be character-relative, meaning they have to work independent of where your character is facing.

You solution worked. I had to fix a few other things before I could test it but I tested it today and it works flawlessly. Thank you.

Is this thread dead? I’ve been struggling with directional combat creation for over a month now >.<

I guess you could say it’s dead in the sense that no one’s commented on it in a long time. However, there is a correct answer here that works. It worked when I tried it, the person providing the solution found it worked, so just look at it and see if you’re still confused.

Absolutely awesome, the solution works beautifully, and I, too, tried solving this problem without some much needed guidance on DOT product (or the Normalize function). But yeah, this works flawlessly, and I even implemented dodge-rolling in relation to the actor’s right vector. Long live DMC mechanics lol

Hello, someone can past again the link ? Because i can’t open it.