I have a shooting darts (KinematicBody2D) that will stick on a moving wall (staticbody2D).
I wants to let the dart stick on the wall, which is moving over time by changing position.x.
However, the dart does not follow fully the moving path of the wall.
I end up adding pinJoint2D, but setting the node via gdscript only give me an error
Invalid set index 'node_b' (on base: 'PinJoint2D') with value of type 'StaticBody2D (StaticBody2DWall.gd)'.
My code in dart node for setting up pinjoint2d goes as below:
var slide_count = get_slide_count()
var collision = get_slide_collision(slide_count - 1)
var collider = collision.collider
$PinJoint2D.node_b = collider
Anyone please help. Please let me know if there's a better practice.