Cancel attack when wall is hit

I tried a few hours ago to make a realistic attack event. If the characters sword or arm will hit a wall when its attacking, then the attack animation should get canceled right at the impact and play the attack in reverse.
what I did had completely no effect and the line tracer that i attached it to the sword using Get Socket Location and Rotation did not seem to rotate along with the sword.
I also searched for tutorials of how to do that, but it did not include anything about wall hit with sword.

How can I do this? Are there actual tutorials that I couldn’t find?

Could you not add box collision to the sword BP and use that to detect any collision or overlap?

This model I’m using has a sword as arm, which means it’s permanently attached to the body mesh. but I don’t know how to get the line tracer have the same length as the sword and rotate perfectly with it by being attached to the mesh’s arm bone. I tried using the break and make vector in the “Get Socket Rotation”, made a - Float on Z to 20 or whatever the size it needs, and it doesn’t rotate with the bone as it should. Location has no problems, but the Rotation does

Sorry for long writing…

Isn’t @pattym correct? Attach a box or capsule collision to the sword/arm. Turn collision ON during the attack. If it collides with a wall, turn the collision OFF and play the cancel animation … or reverse the animation, as you say. Seems like you’re over thinking it to me.

So its that simple to make such detail? Then i’m gonna have to find out and see If it was that simple.

Guess not, I have not idea how to make the hit event fire when the collision box collides with a static mesh (a white cube for example), even if I set both collisions to true and check simulation generates hit events.
I tried like this to see if it generates or not:

It’s something I never did before. What else do I need to add??

So the general issue with tracing melee combat is that the animation moves a discrete amount each frame.

If you attach a kinematic collision object to the weapon it will jump between frames - you need to make sure that the movement is swept to properly detect collisions.

Thus, you need to sweep some kind of collision representation of the weapon. The endpoints of the sweep should be the weapon locations between the frames you are interpolating.

This way, the wall is detected during the sweep and the animation can be changed.

Very fast swing animations will fail to generate a nice arc - for that you should use a custom designed swing sweep.

Also - remember to use Branching Point instead of Queued(the default) in the AnimGraph, otherwise the animation change may be delayed.

I recommend using Rama’s Melee Weapon Plugin to save yourself some time.

It does the PhysX sweep for you.

I use an animation of 60 frames per second to look smooth

I don’t understand, I haven’t learned yet about the sweep, nor I need to add swing sweep effect in this one.
Also what does it has to do with the blueprint I showed above?

I know that from the Climbing Tutorial video

Unfortunately I have no money for that :confused:

How can I make the collision box for the sword to create the hit event with any objects or actors it collides??? The problem is not solved yet

It appears that in order for the event hit to trigger, I just have to enable “Stimulate Physics” which means that if the player runs on that object with the physics enabled, it will move, I don’t want that to happen, I want the event hit to trigger on static meshes, but doesn’t want to get triggered for some reason. The collisions on the collision mesh or capsule collision are set to block all, and so in the object mesh. Why isn’t the hit event triggering with static meshes???

Ok, in order for the collision box to trigger a hit event on a static mesh, you don’t need a hit event, you need a overlap event. Logic works like this, hit = physical objects, while overlap = static objects

Topic solved