0 votes

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!

in Engine by (378 points)

1 Answer

+1 vote
Best answer

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
by (19,272 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.