How do I add a child node to the mouse?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By elrico26

Does anyone know how I add a child node to the mouse to follow

:bust_in_silhouette: Reply From: rakkarage

code:
https://github.com/rakkarage/PixelInterface/blob/main/PixelInterface/Cursor.gd
demo:

ya it is to put a sprite to the mouse… but it does that by making the node follow the mouse… what should it be a child of?

rakkarage | 2020-10-20 16:00

:bust_in_silhouette: Reply From: Asthmar

In the child’s node script, under the process function put

global_position = get_ global_ mouse _pos()

This will set the position of the node to the mouse. There may be a better way of doing it.

subtract x value from the global mouse position

Asthmar | 2020-10-20 16:55