Changing a joint length - player input

gitborggitborg Posts: 1Member
in 2D

New to Godot and the forum so hi everyone.

I've been trying to change the length of a 2d joint, but haven't had much luck so far.

The plan is that when up is pushed the distance between two assigned nodes decreases and when down is pressed increases.

var grooveJ

func _ready():
    grooveJ = get_node('/root/Node2D/grooveJ')
    print(grooveJ.length)
    pass 

func _process(_delta):
    if Input.is_action_pressed("ui_up"):
        grooveJ.initial_offset -= 1
        print(grooveJ.initial_offset)
    if Input.is_action_pressed("ui_down"):
        grooveJ.initial_offset += 1
        print(grooveJ.initial_offset)
    pass

On running my code there is a static body node assigned and a rigid body that swings, but the increase or decrease in length although it prints has no effect on the distance between the two nodes. I've also tried with 'length', also spring and pin (although pin has * no obvious distance control).

Is there are well known way to do this kind of thing that I've not been able to find?

Thanks in advance for any responses.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file