How to have character react to physics?

So I want to get the AI and player characters to react to physics. Let’s say there are two attacks: explosives and hammer attacks. In both cases, force should be applied to the characters. Everything’s fine and working as long as the character doesn’t have a Character Movement component. But both do, so the player and the AI can control their movements.

I know that such physical forces and effects don’t affect the player character because it doesn’t have Simulate Physics enabled. If it is enabled, then it can’t be controlled by the player (or at least doesn’t move).

So the question is: what is the best way to achieve this? I think I may have to fake the effect somehow, like move the player in the direction of the hit normal, but how much? That’s why a computer controlled simulation would be best, and not a predetermined direction and force. I’d like to have a realistic effect (so if the player character is away from a weak explosion, it shouldn’t fly through the whole map, obviously).

I’ve tried enabling Simulate Physics when a hit event occurs, but it fell into the ground and other ugly things happened, so it’s not the way to do it.

Any suggestions are welcome.

Thanks

Even though physics are disabled the character movement component does provide a couple of functions to make the character move around in a physicalish way.

Namely: AddImpulse and AddForce.

When your character is hit you can get the impulse or distance or whatever of what is supposed to trigger the physics impulse. It should be easy enough to detect a character within action range.

When that happens you can apply an impulse to throw the character away.

Your alternative is coding your movement yourself which can be challenging.

Cheers!

How would you use them? because when I try to add impulse to my character, I get the error “… CollisionCylinder has to have ‘Simulate Physics’ enabled if you’d like to AddImpulse”
and of course it doesn’t move

It’s a function of the character movement component. Not to your capsule component.

That one takes over all movement. It has some similarly named utility functions.

thanks, that seems to be working for now