Dynamic height vaulting?

Godot Version

v4.2.1.stable.official

Question

Hello all. So right now I have a system set up where the character can hang from a ledge. There is then an Area2D detecting whether there is space to vault above, if so then upon pressing button a vault is activated and your character goes up and over the ledge using a tween with hard coded values for how far the character will travel. Now the complexity comes in because I’m going to add features where you can vault over ledges of various heights and there are some edge cases with crouching and prone position etc. so I need a way to be able to make a more precise vault to accommodate various heights but I’m not sure how to go about it. Maybe I can snap the body to the edge so it follows it closer but I’m not sure lol, any suggestions would be appreciated, thank you.

Here is one approach you could try to determine the ledge height:

  1. Shoot a horizontal ray towards the direction of the wall (hit point: hPos)
    to detect the x-position of the wall
  2. Shoot a vertical ray downwards from the hPos + epsilon to detect the
    y-position of the ledge
  • epsilon: a small value that is used to avoid an edge-case where the ray narrowly avoids the target due to a floating-point error.

image

After this info is obtained, it’s just a matter of performing an animation at a specific position relative to the obtained point.

Great solution, your reply got me going on the right track though still got some kinks to work out. I have a long downward ray which is slightly taller than the character and a function which returns the distance from the collision to the origin of the ray. I can then use the info to tell how far up the character will go. This will be good too because I’m going to make it so that depending on where it is colliding I can have the character vault over obstacles while running or vault over a ledge while hanging from it, etc. Thank you again

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.