Download

Pushing a NPC away.

I’m trying to implement something like the Aard skill from the Witcher games. The NPC should be pushed away the player activates the skill and it is in range (I’m using BoxTrace to know if the NPC is in range). The way to do this is just turning off the AIController and turn on the Physics for some time and then revert the process? Any suggestion?

Does any one have any idea about this?

Guess it depends on what you mean by “Push”. Do you want them to go ragdoll and flop away? I don’t know what “Aard” is as I’ve never played The Witcher but I’m picturing a Fus Roh Dah. If that’s what you want, yeah I would enable physics and use the “Force” node (Apply force? Add force? I don’t remember the name) to push the ragdoll in a direction. If you don’t want them to ragdoll, I do believe there is an “Add Force” node that can be attached used on a pawn’s movement component, though I’m not certain what it does.

You would use the LaunchCharacter node. However, keep in mind that pushing a character with any method could potentially push your NPC off the navmesh.

Thanks for your answers, guys. @Chumble Here’s a video of what I mean by aard and push https://www.youtube.com/watch?v=RGdkG56VCsI
@Nerdsbeware I tried LaunchCharacter with no success, but my question is if I had to turn off the AIController and let the physics take care of the NPC’s movement. I haven’t had success with this approach till now. I’ll keep trying. Thanks again.

I’m not sure if this is the best way to do it (or if it’s what you’re looking for), but it’s the best method i’ve been able to come up with so far (and i’ve tried many things :)) Any other methods would be awesome to learn about if anyone is willing to share also.
Have tried to comment everything clearly for understanding.
How you initiate the event of course is up to you (overlap or hit)

In the below set up I’ve used a spring arm set to inherit yaw that points out behind the character and have placed an arrow on the end of that spring arm and called it “Knockback Position”, the reasoning here is that the hit character will always be pushed away from the pusher in the direction of the push. (I’ve used a set rotation prior to running the set location to make the pushee look at the pusher, which sets the spring arm in the correct position). Of course getting a “Push To” location could be achieved in a bunch of different ways.

I’ve used the launch character methods and add impulse and add force but found all of these methods too clunky, most likely due to my inability to apply them properly. :slight_smile: