Creating/changing a joint mid-game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Radinyn

Is it possible to add/edit a joint (GrooveJoint2D probably suits it the best) between two objects when the game is already running? I mean between two bodies that are not colliding at the moment, some kind of stretchy line between them?

You can edit a GrooveJoint2D at runtime. Access the mesh though its node name or through an instance. For example:

# The node in question
if someone_was_hit:
    # Someone was hit hard. Change the length of the joint to show how hard they were hit.
    $GroovyJoint.length = 100.0

Hope this helps.

Ertain | 2020-04-25 17:29

When I try to connect two nodes with the GrooveJoint I get the following error and the connection just doesn’t happen for some reason:

 E 0:00:05.322   k_tensor: Condition "determinant == 0.0" is true.  
 <C++ Source>  servers/physics_2d/joints_2d_sw.cpp:249 @ k_tensor()

Radinyn | 2020-04-25 17:37

Some more information:
Im trying to connect a Kinematic Body to a Static body

Radinyn | 2020-04-25 17:51

Since joints (like Joint2D and GrooveJoint2D) have properties, they should be accessible through code, and can therefore be changed as at runtime. Maybe I’m mistaken? :-/

Ertain | 2020-04-25 23:37

It looks like for some reason they don’t want to connect at all because of this error I posted above

Radinyn | 2020-04-26 10:01