Melee block Blendspace


I want the character to block melee attacks and hold his weapon up, down or sidewards depending on the hit direction automatically.
To do that I made a blendspace:

Inside the AnimBP I try to lerp between the current BlockAlpha and the target BlockAlpha.
So for example if BlockAlpha is currently at let’s say 0.5 and since the attack is coming from above, the character should hold his weapon above his head, thus BlockAlpha
needs to be a value of 1.

But no matter what I do, the value lerps to the target value very slowly. (I tried different values for InterpSpeed)

So where is my mistake?

Don’t know how to help you here, but I’m also making a directional attack/block system and the last post in this topic helped me a lot


For anyone’s sake that will be looking over your code. You need to rename the axis Block Alpha to something else.

animation wise Alpha is usually used for applying or not applying an animation - so whenever someone reads the variable you immediately cause confusion.
Unless that is precisely what it does, in which case I believe the way you are using the blendspace is creative but counterproductive.

anyways, in your code the variable Time may be wrong.
what is it set to, and why is it set as a variable?
you should plug in the correct node to get the time from the last tick.
Try changing that variable’s value to see how it goes.

Also, to know if it is working correctly or not, set the interp speed to 0 and see if it instantly changes.

further, the issue of how long it takes could be due to how this function / event is getting called in. is it called in once, or repeatedly?

My reccomandation for making the block system would be to refactoring the whole thing and go the state machine route.
the interpolation between one state and another happens on it’s own with a smooth transition - you can literally use a 1 frame animation set to loop and the system should interpolate between one pose and another however fast you define in the transition states.
granted- it would become harder to change that value based on gameplay effects. It’s not impossible, and it may be better in the long run.

I changed the name “BlockAlpha” to “BlockDirValue”. Before I try different things out, here are some answers:

I set the Time-variable in the AnimBP:

Setting interp speed to 0 doesn’t do anything. No matter which speed I try the transition from an “even” blocking to the top blocking goes still very slowly.
Here is a screenshot for better imagination:

I call the Blendspace inside the idle state of the Locomotiongraph:

The function is called inside an AnimNotifierState. It sends a message to the target actor that is being attacked (in this case the target actor is the player). The
player calls the custom AnimBP, which I posted a screenshot of above. So I think the custom event is called once. I thought since I’m using an Anim Notify
State it is called multiple times…

I try to accelerate the BlockDirValue with a timeline, but that doesn’t help either.

I purchased a very good asset called “Dynamic Combat System” where the BlockAlpha value is also set and updated with a timeline inside the character BP. I’m not sure whether I’m allowed to
post a screenshot from this piece of code.
I thought maybe I would need to create an AnimOffset additionally but this messes the animations up very bad. I need to look at it more deeply still.

Maybe the blend poses by bool is what is taking too long?
What is the idea behind those?
meaning, why not just split the whole thing into 4 or even 8 state machines?
it will make the whole system much more intuitive without the need of a blendspace, timelines, transitions etc.

also, anim notifies aren’t exactly reliable for timing things exaclty. Just keep that in mind.

Generally, block is a result of 2 things. A button press and an incoming attack. Both can be considered 2 boolean.
then you also have the incoming direction. You can easily use 1 integer or even float for this, with the numpad numbers as the direction map so it’s easy to know what is where.

Each state will have to transition from itself to each of the others if both the 2 boolean are correct and the direction is appropriate.
if using an AI you can override the block boolean via AnimBP for easy testing and an impassable guard (then usually you write the AI to not be right all the time, via random # and a percentage based on how good the enemy is supposed to be - random 0 to 99, decent enemy blocks if number is < 75 for instance.) Besides the point I guess.

Anyway, it’s not quite clear how - aside form the notify - the function is called.
if it is not called with a button press, then finterpto would only run for the moment it is called. Afterall this event isn’t recursive, and you aren’t calling it again until the finterpto is finished.
a timeline would fix that, in your screenshot it’s not connected, but I’m sure you know that.
however, try testing it by just using a print screen and the output of the timeline, with nothing else. Keep it super simple.

A few weeks ago I set up an AimOffset. That is what the blendspaces are for. But that doesn’t work correctly either. (I posted it a while ago but I can’t seem to
find that old post right now…)
But anyway…

But than it would be hard to get the moment where the AI should parry or dodge. For blocking I can determine the hit direction but for the rest I don’t have any idea
how to manage that except using AnimNotifiers. Are there more ways to get the good time stamp for the AI to react ?

The timeline doesn’t accelerate the transition. At least I couldn’t get it working yet. That’s why in the screenshot it is unplugged.

On the right top where drew the red circle the value is supposed to tell the AnimBP where to hold the sword at. Inside the AnimNotifier I send a message to the target actor with this value.
So if the attack animation does movement where the
sword comes from above, the number “1” should move initiate blocking movement where the player blocks to the top:

If the value is zerso, we would block from the center. But yes, the function is called only once.

But regarding your suggestion: Do you mean something like this ?

Instead of using an AnimNotifyState I put everything inside a MontageWindow. Now the custom event inside the AnimBP “UpdateBlockAlpha”
is called more than once. But the transition is still very slow. Is there really no way to increase the transition between two blend poses ?

Pretty much yes for the last image.
except I’d have all 4 sides and no block on idle for the player.

Re your question on the anim notifies. They aren’t 100% reliable, that doesn’t mean they don’t work. With AI in mind they provide some sort of built in randomness.
they remain the best solution, as the animation needs to drive those.
The only other alternative would be to manually trigger based on time remaining node of the animation.
You would get more accuracy, probably, but at the cost of coding a solid checking system to see that the anim playing is the one you need and the time elapsed is correct. So unless for some weird reason you really need the precision, I’d leave it at an anim notify.

So I did for the transition from BlockIdle to BlockTop and the state BlockTop:

And it seems to work now. The transition goes pretty fast, thank you! But sometimes it is stuck at BlockTop for a few frames instead of going back to BlockIdle.
But nonetheless I think I would still need BlendSpaces for each single block direction. Otherwise the player would always face into one direction while blocking.

Within the state you can actually use blendspaces as well, I’m just not sure how or what you mean in terms of facing.

What you could possibly do is to cache this pose and manually place it on the top slot so that the rest of the animations can work much like a montage.

At least I think you can. I remember making something like this but it was about a year ago now.

Another, maybe better alternative is to set up a root bone rotation or a pelvis bone rotation via code to just keep the bust oriented to the other player during the block.

Think of it as an auto aim. You just use the look at node to get the rotator and apply it to the bone in world space.

If you do this with the root bone, and you also have turn in place setup, plus the slot system, it should be pretty much all you need for close to an AAA feel.

Alright. So I googled to find tutorials on bone rotations and found this one helpful: UE4 Character Look At Tutorial - YouTube
I did everything he does except that I put the Transform (modify) bone-node inside the AnimGraph and instead only rotating the head I tell him to rotate pelvis. (it says “spine_01” in the picture because I was playing around at that moment.)
But I am getting weird warnings and I can’t find anything in the web:

This is how everything looks like now:

and at the end of the UpdateAnimation Node inside the Event Graph (AnimBP) I call the function like this:

In the preview the bone rotates fine. I’m having weird timing issues and have no clue how to fix that or don’t know where to even look.