Jump to Swinging Rope?

Godot Version

4.2.2

Question

Hello all,

I have a question regarding jumping to a swinging rope (a single sprite) using an animation player that I can can’t solve correctly.

I have the player code making a connection to an animatable2d object that has an area2d node at the end of the rope - I put everything concerning the rope in a group called “rope”. The rope is swinging and the character is making a connection.

Yes, the connection area should be smaller on the rope but this is proof on concept. The connection area should also be smaller of the character as well.

The problem is that the character does indeed jump to the rope and start following the radius of the swing, BUT, he keeps going further and further down the screen until he hits something and goes back to the collision spot on the ‘rope’?!? Haven’t made it possible to jump off rope yet. I can’t figure out why - is it because the character isn’t on ground and therefore the velocity.y is in effect? The code used to swing the character is below. To me, because the position is set to a global_position shouldn’t that override the gravity/velocity.y?

if (rope_grabbed):
		print("...tarzan...")
		global_position = rope_part.global_position;

The code for the collision is here:

#to grab ahold of the rope
#used instead of body entered because that is not available
#on character2D
func _on_grab_zone_area_entered(area):
	##check this code first to see if area works
	if( area.is_in_group("rope") && can_grab):
		print("Grab the rope baby!")
		rope_grabbed = true;
		rope_part	 = area;
		can_grab 	 = false;
	#pass # Replace with function body.

As always any help is greatly appreciated.

Regards.

Don’t worry figured it out. It was indeed the gravity causing the character to slowly go down off the ‘rope’, but, following the arc. Just needed to zero out the gravity:

  • velocity.y = 0;

when on the ‘rope’ :sunglasses:.

Regards.