Download

Enemy Knockback + Physics Ragdoll Force

Hi everyone!
I’m currently trying to implement a knock-back effect whenever the player hits an enemy with an attack.
So if I shoot a weapon or a projectile hits the enemy, a vector variable is set called “Hit Location”, where the collision happened.
When the enemy still has health left, I just want to push or “knock-back” the enemy based on the location where it was hit.
I’ve searched through the Answers Hub and here, but the best I could come up with was this attempt:
4485a588bfec93c7331003851e13b9f7fc2e29fc.jpeg

But this does not seem to actually shove the enemy back, but it shoves it in weird directions and sometimes with more force and sometimes with less…?!?
I really suck at vectors…

Also if the enemy is dead I turn it into a ragdoll. This works fine by turning “Set Simulate Physics” on. Now the Hit Location should be used to “Apply Force at Location” to the ragdoll, so it flies away from where the bullet hit the enemy. But I don’t really understand why I need two vectors, one for location and one for the force. I’ve tried to look up a way to calculate this, but I couldn’t find anything that explains how to set this up correctly.

Could someone please tell me how to do the two desired effects?

A friendly bump
Nobody has done this before?

Maybe since it goes in random directions, is because you are adding the force right where collision happened, which I think is pretty close to the character. Maybe add force a few units before the collision location?