In this tutorial, we will see how to rotate a sprite on its own axis using code and animation
- Select the sprite you want to rotate.
- Go to inspector and create a new script.
- Add the code below to the script.
- 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
- Select the sprite you want to rotate.
- Click add node and add an animation player.
- In the animation windows click on animation button and create a new animation.
- Go to transform>rotation in the inspector window.
- Set the rotation for different timeframe and click on the key icon near rotation.
- Play animation to see if you have the desired result.
