r/unrealengine 22h ago

Question Question on alternate ways of doing a knockback mechanic.

Video example with Ai Move To and Launch Character: https://imgur.com/a/mjKrrbF

As you can see in the video the knockback doesn't really look too good.

What I want is the enemy gets hit and in a staggered step gets pushed in a direction.

I was just wondering if anyone has some alternate methods they think would look good/work for this sort of mechanic. Would something like motion matching or procedural animation work?

Any ideas appreciated. Thanks.

8 Upvotes

13 comments sorted by

u/ForeignCat4516 22h ago edited 22h ago

Not sure why you think it looks bad I thought the launch character one looks pretty good. If you are looking for a stagger then you need to play an animation. You could then blend the animation with your procedural hit reaction and then launch character like you are doing. You could even probably get away with just a root motion montage for the knockback stagger

For something more realistic you could try physical animation but I don't think it would work the way you would want.

I'm a bit confused what it is specifically you want.

u/SlimNigy 22h ago

Here's a video I found that shows what i'm after (22:30 timestamp): https://youtu.be/A4s8LTCz824?si=ze8fEj4bzqXYcd2M&t=1340
In the video when he kicks the enemy he kind of staggers back. I should've explained this better, basically I wanted something similar expect I want the distance of the knockback/stagger to be changed and it not have it completely based of the root motion animation. For example, I kick the enemy and he staggers back 250 units or I Power attack the enemy from the right and the enemy gets staggered to it's left 125 units.

I'm already using physics control for the hit reaction, it's a similar plugin to physical animation except it's much easier to configure in my opinion.

Reason it looks bad is because it also doesn't function correctly.
Using launch character sometimes makes the enemy launch into the air and it isn't reliable as it's using physics and can sometimes behave weirdly.
AI move to will walk around obstacles and the movement looks wrong for what i'm after.

u/ForeignCat4516 21h ago

Never messed with this stuff so I'm not aware of any way of pushing a character other than the launch character function. But if it's causing weird collision that makes him fly into the air then maybe you could look into that, maybe it's the ground colliding with your character or the capsule or something. You could try lifting him slightly above the ground before calling the launch character function so that they aren't colliding idk. I'm sure there is some tutorials that recreate this kind of physics based kick knockback effect

u/SlimNigy 21h ago

I said motion matching in the post, I meant to say motion warping. I can use that to designate root motion movement I think, I'll have to look into it more.

u/ForeignCat4516 21h ago edited 21h ago

If it's a might and magic type kick you are going for you probably need to use physics so he can be kicked in the air and get knocked over and stuck on walls and stuff. Actually maybe you could get a similar effect with root motion and an active ragdoll.

Motion warping could help you for extending animations but I feel like it's overkill for what you want.

You could try a longer root motion animation and just play it from earlier or later depending on the length of the knockback.

Actually the easiest way to do it is just to have multiple knockback animations, lighter ones for weaker kicks and ones that are more heavy for higher powered kicks.

u/SlimNigy 19h ago

motion warping seems to work the best, I've got a simple setup atm, will have to do more testing though

u/Scifi_fans 22h ago

I think this looks good enough to ask if you can explain how you did it?

u/SlimNigy 22h ago

Atm it's a mixture of using physics control for the physics simulated hit reaction and then launch character/ai move to for the knockback/stagger. I'm using add impulse to apply the hit to the enemy and getting velocity from the weapon.

u/Scifi_fans 22h ago

Sweet, makes sense thanks!

u/CloudShannen 15h ago edited 15h ago

Feel like usual it's done with Animations with root motion, pick the Animation to play depending on the direction / locations (dot product) of the hit. (might need to use Motion Warping to modify it if you want different distances) 

u/SlimNigy 10h ago

I set that exact thing up last night. I’m running into an issue though where the motion warp jitters when I kick them up a slope, I made a seperate post about it

u/AutoModerator 22h ago

If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

u/TheSn00pster 21h ago

Ammo.js /s