So i am trying to make a rope between player and where raycast hit in 2d godot.I have rope piece instance with rigibody/staticbody and pinjoint. So what i am doing is spawning enough pieces as a child of a gameobject between player and collision point of ray and the rope is spawning good enough but rotation isnt working. I have tried everything but its just not working.
Here is my horrendous code
elif Input.is_action_just_pressed("shoot") and ray.is_colliding():
$".".gravity_scale=0
var positionPlayer=$".".position
var total = ceil(positionPlayer.distance_to(ray.get_collision_point()) / gap)
var rays=ray.get_collision_point()
var playerPos=$".".position
isSpawned=true
for n in total:
if(firstTime):
var pos=ray.get_collision_point()
pos.y+=25
pos.x-=35
$"../ropewa".position=pos
obj1=ray.get_collider()
var rope=ropePiece.instance()
$"../ropewa".add_child(rope)
obj2=rope.get_node("PinJoint2D")
obj2.node_a=obj1.get_path()
obj2.node_b=rope.get_path()
obj1=rope
firstTime=false
if(n==total-1):
var rope=ropePiece.instance()
$"../ropewa".add_child(rope)
rope.position=obj1.position
rope.position.y+=add
obj2=rope.get_node("PinJoint2D")
obj2.node_a=obj1.get_path()
obj2.node_b=rope.get_path()
$".".get_node("PinJoint2D").node_b=rope.get_path()
else:
if(firstTime==false):
var rope=ropePiece.instance()
$"../ropewa".add_child(rope)
rope.position=obj1.position
rope.position.y+=add
obj2=rope.get_node("PinJoint2D")
obj2.node_a=obj1.get_path()
obj2.node_b=rope.get_path()
obj1=rope
what I am doing is spawning a rope piece and joining the old rope piece and new rope piece. ropewa is the gameobject with all the child inside of it.$"." is the main player.
My solution so far
