Aiming with joystick stop working when transforming pivot point

Godot Version

4.2.2

Question

Hello, i’m very new to programing and godot. I’ve been trying to implement an arrow that rotates around my character and that I can aim with mouse or joystick (to use a hook).
So far I’ve used this technique wich works perfectly for the joystick direction with input strenght converted into a vector:

func _input(event): 
	
	var arrow_visibility = arrow.visible
	var look_vector = Vector2(0,0)
	
	look_vector.x = Input.get_action_strength("aim_right") - Input.get_action_strength("aim_left")
	look_vector.y = Input.get_action_strength("aim_down") - Input.get_action_strength("aim_up")
	
	if Input.is_action_pressed("hook_pad") and can_grab and not_grab_on_cd:
		arrow.visible = true
		pivot.look_at(position + look_vector.normalized())
	if Input.is_action_pressed("hook_mouse") and can_grab and not_grab_on_cd:
		arrow.visible = true
		pivot.look_at(get_global_mouse_position())

The thing is, I need to move my pivot position to something else than 0,0, and when I do that it stops working with the joystick. The arrow isn’t following anymore and it’s barely moving in only one direction. But it still works perfectly with the mouse.

This might be stupid, I know it as to do with moving the pivot position but I can’t figure out why exactly. If anyone as an explanation it would help a lot. Thank you !

Video for maybe clarification :
arrow_example

I managed to fix the issue by just moving the visor script directly inside the pivot node . Previously it was on my character script probably making the “position” all wrong. I knew it was that easy ahah.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.