I want to add trimping or trick jumps to my game, but the method I currently use only works when I jump on a ramp. I want it to work when I walk off ramps as well, which I did implement but it was too jarring and looked more like a dash.
So I’m thinking there has to be another way.
I run the trimp function after I jump btw.
The current code:
@onready var normal:Vector3
func physics_process(delta:float):
if ground_normal_ray.is_colliding():
normal = ground_normal_ray.get_collision_normal()
func trimp(multi):
if not normal.is_equal_approx(Vector3.UP) and not normal.is_equal_approx(Vector3.UP):
var tangent = normal.cross(Vector3.DOWN)
var slope = normal.cross(tangent)
if slope.y < 0:
slope = -slope
var speed_at_slope = velocity.dot(slope)
velocity += slope * get_real_velocity().y * (speed_at_slope*multi)
Can you describe the problem in a bit more detail?
Is it jarring and dash-like because it changes the angle of movement in some way, or does it just give a short lived burst of speed that is quickly lost?
From the code you’ve posted (I think) you should currently be gaining velocity in the angle of the ramp at a magnitude proportional to the vertical component of your velocity and some multiplier. Sounds like it should work!
Yep, it does, just the dashing thing.
They way you said it, it’s a short burst of speed that is lost fast.
I’m not sure how to prevent this.
I’m going to try to make an extremely small multiplier and make the trimp function work when on the ground and see if that works, otherwise I’m clueless.
That sounds like a good plan.
If the speed is lost too quickly after leaving the ramp you could also allow it to keep applying the speed boost for some amount of time after leaving the ramp, perhaps with a dwindling multiplier.
Good luck!
1 Like