0 votes

I have the following scene structure:

KinematicBody2D
-Sprite
-Position2D

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

Thanks for answers!

asked Feb 23 in Engine by Godot_Starter (266 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
answered Feb 24 by jgodfrey (6,576 points)
selected Feb 24 by Godot_Starter
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 How to use this Q&A? before posting your first questions.