Godot Version
4.3
Question
My current setup uses a ray cast in front of the player to get a point to lock itself to using a Pin joint. when I try to move the pin joint there, it instead moves itself to the right of the player.
the colorRect is a child of the pin joint, there is a barely visible raycast protruding from the front of the player.
here is the player script
extends RigidBody2D
var horizontal:float
var vertical:float
const speed := 2000
const turnSpeed := 40000
@onready var grapple := $grapple
@onready var pin := $Pin
func launchGrapple(): #called when the grapple button is pressed
var anchor = grapple.get_collision_point()
print(anchor)
pin.position = anchor
#steps to be executed
#move the pin node to the anchor point
#set the pin node to pin the player to a staticbody somewhere (the location of thestaticbody doesn't actually matter)
#on release, break the pin by pinning the staticbody to itself
#wait until the grapple is called again, and repeat the process.
func _process(delta):
horizontal = Input.get_axis("left", "right") * turnSpeed * delta
vertical = Input.get_axis("up","down") * speed * delta
apply_central_impulse(transform.y * vertical)
apply_torque_impulse(horizontal)
if Input.is_action_just_pressed("grapple"):
launchGrapple()
the grapple node is the ray cast i mentioned, the pin node is the pin joint I’m attempting to move. I’m guessing that It’s something to do with the pin joint being parented to the player, but I’m not sure yet. It’s also worth mentioning that the pin joint is only connected to the player, so It doesn’t actually do anything yet
please help!