How to make a animation reach the ground no matter the height?

Hey all, I was wondering if someone could help me with this:

As you see the animation stops before it hits the ground, my question is how to make the animation always hit the ground, no matter the distance.

I have a variable to stores the distance between my character and the ground beneath it with a line trace, I just dont know how to apply that for animations

Thanks any help is appreciated :slight_smile:

Hi there,

That happens If your animation uses root motion enabled. To change that, there are two methods

  1. Extract root motion to curves and use line traces to track the distance, start and end location
  2. Use motion warping which is a plugin still experimental.

I’ll see if I can find a good tutorial.

1 Like

What on earth does root motion have anything to do with this?

@Faze_Kaas
Look into how to properly make a jump animation work in games.

You need a single frame to loop until you detect the foor, then you play the landing animation.

And yes, you can do this with a montage and looping parts of it.

To your question, the animation shown clearly has root motion enabled, that’s why it stops mid air. If he wants to use the same montage in any circumstances, in place animations will require a different setup.

Yes I already knew how to do that, but part of my landing animation is in air, so that is why I asked, I dont know how to make it so the landing animation plays correctly (If I jump from lets say 25m the landing animation needs to start playing sooner than when I jump from 5m) So maybe its a bad formed question from me, but I basically want to try to start the landing animation based on how much time until the character hits the ground

Thanks I will look into it, do you perhaps also know how to calculate the time until the player hits the ground?

That’s tricky, there’s a node “get floor” you get from movement component that traces the floor distance. You need math based on your falling speed and distance.
That’s why I would prefer motion warping, all hard calculations are done for you. You only need trace locations with for loops.

The other setup suggested by MostHost_LA are typically seen in hack-n-slash games, perhaps you’ll find a tutorial showing this technique. Unfortunately, I can’t help you with this. I am not familiar with this gameplay mechanics.

This hasn’t been the right way to do it, Probably never was. But in a pinch you can get what you need intellectually to create something which works for your montage.

I have it working, but for the 1 animation (but I want to use the 2nd one shown in the video) when I try to change it, it does not work properly anymore: ? - YouTube
I changed the character Z value (the line trace down) to a higher number so that (I would think) the animation starts playing sooner, but that wont work
Do you have an idea of why that is?
I will take a look at the video you send me
Thanks

Yeah that is true, I will have a look at motion warping and see how that is

Hi
Keep in mind motion warping is still experimental, so make sure to test it in a packaged game before committing to more coding in your final game. The sooner you test it, the better.

… the trace has a start point which can be altered, and and end point which can be altered.

The returned hit value distance is always variable and is calculated in the positive, from the start to the hit location.

Normally greater result value means a greater distance from the floor if positive.

So, depending on what you changed you could be right or you could be wrong.

The value you chose could also be outside the range of the trace, invalidating the whole concept…

Another thing to consider, the distance doesnt mean much of anything if your frame rate changes.

You assume that because the hit point is X distance away you can change the animation to landing, but if the frame rate changes that X distance may no longer be accurate.

You should power the animation transition by calculating the distance in number of frames needed to reach it.
Distance * delta time or something similar.
(Delta time is almost always less than 1 so it shoud be distance over detla time in practice).

By the result of that - say it currently gives 20 frames - you know that you can transition in 10 frames (or whatever your landing animation is timed to do).
So the trace has to keep running until it returns 10 frames, when you can transition and disable the trace…