Search code examples
unreal-engine4unreal-blueprint

Unreal Engine 4 - Add offset to character movement


I just started (yesterday) using unreal engine and I need to simulate a drunk character using BPs.

I'm using two camera shakes (one for standing still and one for walking) but I want to add some "displacement" on charater when he's walking. Basically I want to define a random float to be added to X axis location in order to make character wobble smoothly.

It will be acceptable even if there's a way to make the character move along with the camera when it's shaking.

What I tried until now is using AddActorLocalOffset and a timeline to lerp between actor's location and actor's location+offset, but both are very choppy to me.

Maybe it's a noob question but as I told I'm very new to this and need it for a quick work.

Any suggestion?

Thanks


Solution

  • If you are targetting physically correct model, you should use AddForce (UE Docs). But this approach would require implementation of a "drunk animation" where your character will modify it's movement animation to "compensate" this force by stepping aside etc.

    Another (much more simple) approach is by using AddMovementInput. This example can be seen here: UE Aswers. In this case, you are basically simulate player's input by adding small amount of side force here and there.