Move Sprites to Position2D Node

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

I have the following scene structure:


  1. How can I move the Sprite to the Position2D?
  2. How can I rotate the Sprite via Script?

Thanks for answers!

:bust_in_silhouette: Reply From: jgodfrey

You can move the Sprite to the position of the Position2D by setting its transform to that of the Position2D.

$Sprite.transform = $Position2D.transform

Alternatively, you could make the Sprite a child of the Position2D. That would naturally place the Sprite at the same position as the Position2D (assuming the sprite’s transform is 0,0).

You can rotate the sprite using any of:

$Sprite.rotation_degrees = 90 # degrees
$Sprite.rotation = PI/2 # radians
$Sprite.rotate(PI/2) #radians