Godot Version
Replace this line with your Godot version
Question
I have vert logic in my "skate"but it’s simple not doing what I want… the player goes up the ramp perfectly, and even get’s air (for tricks) but when it lands back into the half-pipe it just pops away instead of going back down as you would expect.
Script:
func orient_vert_landing_descent() → void:
skating_enabled = true
brake_stopped = false
var fall_speed: float = max(-velocity.y, 0.0)
var gravity_direction: Vector3 = Vector3.DOWN
var downhill_direction: Vector3 = (
gravity_direction
- surface_up_direction
* gravity_direction.dot(
surface_up_direction
)
)
if downhill_direction.length() < 0.01:
# Flat landing (deck) — nothing to do.
return
downhill_direction = (
downhill_direction.normalized()
)
var downhill_horizontal: Vector3 = Vector3(
downhill_direction.x,
0.0,
downhill_direction.z
)
if downhill_horizontal.length() > 0.001:
skate_direction = (
downhill_horizontal.normalized()
)
else:
skate_direction = downhill_direction
# Small kick so the roll-off starts instantly even if the
# landing ate most of the leftover speed.
skate_speed = max(
skate_speed,
kickoff_speed
)
# The faster gravity pulled the skater down, the more speed they
# get back on the roll-off — a small capped increase (not a boom).
skate_speed += min(
fall_speed * 0.25,
3.5
)
skate_speed = clamp(
skate_speed,
-terrain_speed_limit,
terrain_speed_limit
)
velocity = Vector3(
skate_direction.x * skate_speed,
0.0,
skate_direction.z * skate_speed
)