How to rotate a sprite in Godot

In this tutorial, we will see how to rotate a sprite on its own axis using code and animation

  1. Select the sprite you want to rotate.
  2. Go to inspector and create a new script.
  3. Add the code below to the script.
  4. Save the script and play the game.
extends Sprite


var speed=5
func _process(delta):
	rotation+=speed*delta
	

You can do the same thing by creating a simple Animation in Godot

  1. Select the sprite you want to rotate.
  2. Click add node and add an animation player.
  3. In the animation windows click on animation button and create a new animation.
  4. Go to transform>rotation in the inspector window.
  5. Set the rotation for different timeframe and click on the key icon near rotation.
  6. Play animation to see if you have the desired result.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from VionixStudio

Subscribe now to keep reading and get access to the full archive.

Continue reading