![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ThreeSpark |
Alright, so essentially, I have an “orb” as a child of my player. I have two Position2D children of my player, labelled “r_pos” and “l_pos”. When the cursor is to the right of the character, I want the orb to be in the position of r_pos, and when the cursor is to the left of my character, I want the orb to be in the position of l_pos. Here is my code:
var mpos
func _process(delta):
mpos = get_viewport().get_mouse_position()
if mpos.x >= 0:
position = get_parent().get_node("r_pos").position
if mpos.x < 0:
position = get_parent().get_node("l_pos").position
For some reason, no matter where the mouse is, the orb is always in the position of r_pos. Could someone help me?