CharacterBody2D offset from get_global_mouse_position()

Godot Version

4.2.1

Question

My scene tree and simple code are as follows

All I want to happen is for the icon.svg sprite (the Sprite2D texture) to follow at the exact point where the mouse is. It does this, but the sprite is offset considerably from the mouse. What am I missing here?

1 Like

Is the sprite’s position the same as the CharacterBody2D node? (listed as 0,0,0 in the editor as it’s a child of the CharacterBody2D) Your code seems completely fine, the sprite may just be offset from the node you’re moving. :)

1 Like

Thank you!!! You’re right the sprite position was not at 0,0 - which is what the CharacterBody2D node was at.

1 Like

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