Block Attack?

How does Block Attack work?
Which is to basically block a attack from AI.

You can apply damage with it then make it be a variable bool like block. The player character state can have a variable like “Blocking.” you can give the shield a health percentage, and apply damage for shield attack. It would just be 2 different states in the anim bp, and a shield, or weapon blueprint… Then you could use branch as in attack false, and blocking true.

I was actually about to post a thread inquiring about best practices for something like this for a realistic block.

Going to just piggy back on this thread since its already here, and is relevant to my questions

My question;

How would one go about setting up an AI’s attack to check to see if an attack is being blocked by the shields static mesh? To clarify further…say I had the AI doing a sphere trace or a simple line trace before applying damage to the character, what would be the best & most realistic way to see if an attack is actually being blocked by the vast majority of the shields static mesh? I’ve got a very simple block mechanic in place right now, but it’s basically just an invulnerability state during the blocking animation, and as you can imagine, that is not ideal.

Normally I’m very stubborn and figure stuff out on my own, but the answer to this one just remains elusive to me, which is probably due to my lack of experience.

Thanks in advanced!

I could do something like that, also how about a way to stop the enemies from applying damage when they been hit?

This is something I struggle with so basically the Enemy is attacked but when attacked he still attacks back and knocks some of my
health out is there a way to make sure it does not attack back when its been injured?

To answer your question; I believe if you set the AI’s animation for on hit to be locked in place by using EnableRootMotion, example is attached:

That should prevent the character from doing anything else using animations for the time being, along with locking the AI or player in place during the animation, so provided you have animations setup for attacking, it should act as a stun or stagger period. At least that is how its working for me in my game right now. Both the player and AI on hit received or damage received play a hit animation, are staggered, and cant attack again until the animation is done. You could always shorten or extend the animation playtime to increase or decrease the staggering effect.You could also create a IsStunned Bool, and set that to true on character hit received, then use that as a condition on branches in your AI’s attack to make sure its not stunned or staggered before allowing attacks or other actions. Although that is just really for further control over crowd control effects in the future & the animations should handle that on a basic level without that bool being checked.

About Animations they wont play at all, I made state machines and they are all working fine for AI animations but they just wont play
the only thing the AI does Animation wise is to Run and stay Still but other animations they wont work I don’t know why.

I’ve actually been ignoring the state machine altogether, and just scripting things in by hand currently. Are you defining the variables for transitions between said animations in the state machine (so between run/idle & attack/hit)? I’m attaching a screenshot example of how I have my eventgraph setup for my AI currently. From what you see in the attached image, it goes into a branch with a check if the AI is alive or not, if it is, then it fires off the Play Anim Montage node with the HItAnimation referenced.

You can always just script in the AI’s logic, situational animations in the event graph for the moment, and use Play Anim Montage to trigger animations. Thats what I’m doing for the time being. It’s so far been working flawlessly, and its been less of a headache overall then working with the state machine. Not sure if that is ideal long term or not, but its one way of handling it right now.

What I did was basically how the main character works with State Machines and you make the True / False “Is running” etc…

I have tried to just play the animation but to no success, the character just does the movement thing Floats you know “Still – Running” as for the other thing with
montage its not working either I already tried it.

The only thing it does is just make a twitch when something is suppose to play and that’s it.

I ended up figuring out the animation issues and they play now it was something wrong with the animations themselves so I reimported them and they work fine now.
Also when playing a animation how can you make the character go back to the original animation it was playing as?

I’m not exactly sure what you mean by that. Could you provide an example of what is happening and what you want to happen instead?

That would help me get a better idea of what you mean

Okay so what I mean is when the character is done playing the animation in this case is the Attack animation, what do I do to make it go back to
the main Animation basically the one that the AI starts of with, to go back to the previous Animation it was playing and to stop playing the
Attack Animation.

So the AI was Running after me and playing the animation it catches to the main character and starts playing the Animation “When its not moving” and when
I move away it stops playing the attack animation and goes back to running and playing idle animation “Patrol”.

“What happens when the AI is not attacking is that the animation just gets stuck when its suppose to be moving or switch back to walk/idle”.

Sorry if I cant explain it AI with me is not the best.