V.0.1.1 Devlog - LH


"Undesired Movement During Heavy Attack"

Author: Liam Hans

Posted on: 07/12/24

THE PROBLEM

This week, I underwent the task of adding a bit more dynamism to our combat system. In my opinion, our combat felt a bit empty and "flighty", so I wanted to add a bit more oomph to some attacks - namely, the heavy attack combo. I find that combo attacks greatly benefit when some momentum and movement is introduced during the attack, so that was my goal. I intended to add an impulse to our player when they performed heavy attacks on both the initial attack and the following combo. However, I had a bit of a problem while trying to do this. Normally, adding an impulse to an object in Unreal is rather simple. All you need to do is ensure that object is simulating physics (literally via a checkbox that says "simulate physics") and then you just need to add a call to "AddImpulse" on that object and Bob's your uncle, you have an impulse. This does not work, however, on objects that don't simulate physics. And, you guessed it, our player does not simulate physics. There is a number of reasons why that is, which I won't get into, but essentially, I had to fake an impulse on our player. This similar problem occurred while I was attempting to add a combat roll to our player, so I had an idea where to get started. After a lot of deliberation and experimentation I decided upon using a timeline, which is some built in Unreal functionality that allows you to perform a certain action over a given period of time. So, I used a timeline and set my players velocity to a very fast speed for a very short period of time. This emulates an impulse being applied to my player. This worked pretty well, however I had another problem. When I performed this impulse my character could still move around in any direction, which resulted in some very odd and undesired movement. Below you can see a video of this odd effect:

THE SOLUTION

As you can see, the player can move around after the impulse is applied but before the animation is over, so this would not be satisfactory. However, there was a pretty simple (or so I thought) solution to this. I could just disable input during the attack animation. Unreal has this handy node called "DisableInput" which, as you might imply, disables any input that the user provides for a certain controller. So, I utilized this node during the animation and it had the desired effect. But, once again, there was a problem. Do you know what you need to pay attention to when you're waiting for a potential combo attack? Input. Using this node meant that the player could not apply attack input during the combo window, so they could never perform a combo heavy attack. That would not do. After playing around with some input nodes (and pulling a few hairs out), I finally found what I thought might be the solution. Instead of disabling input, I found some nodes in Unreal that just ignore input. More specifically, they ignore look and movement input, but they don't ignore any other form of input, so I am still able to detect when an action (such as a combo) is inputted. Below you can see the nodes that I am speaking of:

This was my solution. Now, all I needed to do was set the timing correctly and set the input to come back once the attack or combo was finished, et voila, our heavy attack now has movement. Below you can see an example of the finished product with this new system:

Get Plight of the Gods

Leave a comment

Log in with itch.io to leave a comment.