Launching off ramps? (Using character Z velocity while on ground)

Hi all,

I’m trying to figure out how to properly “launch” my character off of sloped surfaces when they reach the edge, rather than just falling off of them. By default the character movement component considers the player’s Z velocity to be 0 whenever they’re on the ground, which causes the player to instantly start falling down once they reach the edge of a ramp. Here’s an artistic rendition of the issue, with the dashed line being the player’s path:


I’ve tried storing the capsule component’s linear velocity each frame (which actually does include Z velocity) and then applying that to the player once they’ve begun falling, but unfortunately that doesn’t seem to work very consistently. Sometimes it doesn’t launch the player at all, sometimes it does, sometimes it doesn’t launch them far enough, etc. I’m guessing this is because the capsule component’s velocity is tied to the character movement component’s velocity, so the capsule component’s velocity is updated to 0 when the player begins falling. I’ve tried only storing the velocity when it hasn’t decreased since last frame to account for this, but that doesn’t seem to have helped.

The next thing I tried was creating a C++ child class of the character movement component to override the functions that zero out the Z velocity. Unfortunately though, most of those functions aren’t virtual, so I’m guessing there’s no way to override them without building UE5 from source and editing the original class.

Any input would be super appreciated, either with blueprints or C++! Thanks!!

Hi,

what kind of movement are you going for overall? Character walking is nothing like the real world physics of a human walking, even if you manage to somehow get the Z velocity in there by modifying the engine source, then you won’t be able to walk over small steps without losing contact with the ground anymore for example. All the walking logic of the character is intent on keeping you on the ground because that’s what happens to real humans, so it’ll probably be difficult to adjust it in a way that gives you the behaviour that you want (especially without causing weird behaviour in other situations). If you want a more physically based type of movement that lets you fling your character around like an object you would probably have to make a custom movement mode or a completely new movement component. With a custom movement mode you could switch between the “normal” movement and the physically based movement.

However, if you are just looking for this behaviour in very specific situations (not as a general way of moving around) you might get away with some tricks like forcing the falling movement mode (which does consider Z velocity) while you push your character up the ramp with an impulse or something.

1 Like