My grappling hook system is broken

func handle_grapple(delta):

	if grappling:
		var grapple_point = $"../grapple_point".global_transform.origin
		var direction = (grapple_point - global_transform.origin)
		var distance = global_transform.origin.distance_to(grapple_point)
		var grapple_force = min(grapple_speed * delta * distance, grapple_max_speed)
		grapple_add_vel = direction * grapple_force
		gravity = 0
		
		if distance < 1:
			grappling = false
			grapple_add_vel = Vector3.ZERO
	else:
		grapple_add_vel = Vector3.ZERO
		gravity = 0.5

My grappling system isn’t grappling me upwards or downwards unless I am already going in that direction. It also suspends me in midair if I place the grappling point on the ground and jump.

I am very new to the engine, so any tips would be much appreciated!

The reason you are being suspended midair is that you don’t add gravity while grappling, and the grapple script moves you to where you need to be.

Where do you use grapple_add_vel? To me, I just see you edit that variable, but not do anything with it.

Thank you so much for answering.

I use grapple_add_vel in physics_process:

velocity += grapple_add_vel

From my understanding, this should add the grappling vector to the velocity vector of my characterbody and move it in the direction of the grappling point, but maybe I need to do it some other way.

So how would I go about fixing it? I am looking to make the grapple script move me in the direction of the grapple point regardless of whether it’s vertical or horizontal. That’s why i removed the gravity while I’m grappling, but that doesn’t seem to work. Could you tell me how I could fix it?
I would really appreciate an answer.

Are you thinking a pull grapple hook in the style of this (not my project, not my sounds), or a swing hook, in the style of Karlson? For a pull grappling hook, they have a GitHub repo with the code and math to make it work (I have used it, and with a few edits, it works well). If you want a swing hook, you can use that as a template and when you start hooking, set rest_length to the length from the grapple point - 2 or so.

thank you man. you helped me a ton!

No problem. Thanks for responding promptly!