I'm making a building system for my top down 2D game, when selecting a item to place in the world I instance a preview of the item, but no matter if I use item.position = get_mouse_global_position or get_viewport().get_mouse_position() the preview always spawns around to 0,0 making it impossible to place it anywhere that's not close to the centre of the scene. is there a way to make a node's position be the current mouse position relative to the scene? Thank you in advance, any insight is appreciated!
make a node position be the same as the mouse position relative to the scene
You want to use the function get_local_mouse_position(): https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-method-get-local-mouse-position
Call this on the object that is a direct parent of the item you are trying to place (what you are adding the item into).
Thank you! using a input check for mouse motion and get_local_mouse_position() did the trick, once again thanks!
a year later
Megalomaniak added the Godot Help tag .