How to make a springboard/high jump mechanic in Unreal Engine 4?

I’m trying to create a springboard (higher jump) mechanic in Unreal Engine. I would like my character to perform a higher jump if the object (like a wall) in front is shorter than, let’s say, 50 cm (Unreal units). I figured I have to use a tracer, which would look if the wall in front of the character is between 0 and 50 cm, and if it is - it would launch the character up, but I have no clue how to assemble it inside the engine.

This is the mechanic that I’m talking about.

Ah so a auto vaulting system.

One trace might not be enough the way I would approach it is:

  1. Trace Forward to see if there is a wall in front. (lets call it Horizontal Trace)

  2. If there is a wall in front than do another trace that will be a vertical trace that starts from a Set Height and goes down to the End Location of the horizontal trace (where the wall was detected).

  3. Now this vertical trace will give you the height of the wall.

Optional: You can do a shape trace to see if there is something else blocking the end location where you want your character to end up after jumping.

After that you can move your character multiple ways either just by launching the character so it can jump over (use Launch Character Function) OR move the character capsule using “Move Component” Function to the hit location of vertical trace.

1 Like

Thank you very much for responding. So in a very schematic way, I think this is what you had in mind. But my question is - what should be the start and end points of both horizontal and vertical trace lines?

Yeah you got it right.

I am currently outside and have a laptop that doesn’t have unreal engine well it can’t run unity let along UE4. So here is a rough image of what you wanna do.

The First Trace starts from your Character Location (GetActorLocation). it ends in the forward direction at a certain range that you will have to play with to see what feels best.

Horizontal
Start Location: GetActorLocation.
End Location: GetActorLocation + (GetActorForwardVector * TraceLength).

Vertical
Start Location: HorizontalTraceHitLocation + Vector (0,0,X) Here X is a value which offsets the trace height, the height from which your vertical trace will start.
End Location: HorizontalTraceHitLocation.

you can easily get the height by doing subtraction of just Z component values of your hit results.

after that is done you can either just calculate the launch direction vector just by doing this:

Launch Direction: (GetActorLocation - (VerticalHitLocation + Vector(0,0,X).Normalize

We normalize the result vector so we can easily multiply our own force value to launch the character and we add the offset on Z so that the character don’t hit wall on being launch its something you have to play with to see which value has the best result.

1 Like

Allright, thank you very much - it works like a charm! In case someone else would be looking for the same question in the future, this is how I set it up:

Now I have to configure it to happen only when the jump button is held, not while running at all times. My last question is - what is the difference between Out Hit Location and Out Hit Impact Point? The blueprint seems to be working with either of them set as my horizontal trace hit location, but maybe I’m missing something there.

As far as I remember when it comes to single line traces the impact point and location are same, only when it comes to shaped sweep methods there a difference.

Docs

As for Jump Held you can use a bool “bIsJumpButtonPressed” and check if that bool is true before doing all this. I would also recommend to add somekind of cool down so the character doesn’t launch way up into air.

1 Like

I’ll experiment with the editor and hopefully figure something out. Thank you again for solving my problem! :smile: