I feel dumb about it, but I’m having a lot of frustration over this. I’m going through Godot’s engine tutorial, “Creating your own Script,” and I followed its instructions in order to make the godot icon rotate in place. Instead, it moves in a circle. I tried messing with the code to see if I did something wrong, and I read both backwards and forwards, even just moving on to it’s next paragraph, the part where it actually teaches you to move the icon, but I’m completely stumped. What am I doing wrong here? Unless I’m missing something, this is exactly the code the tutorial wants me to use for this example.
extends Sprite2D
var speed = 400
var angular_speed = PI
func _process(delta):
rotation += angular_speed * delta
If I had to guess what this means, is I either have the script attached to the wrong node, or perhaps Sprite2D shouldn’t be the root Node? Am I close at all?
Your only suppose to have the root node not the other one. Delete Icon and add the texture to the root node from the inspector panel.
It’s because your script is rotating the root node and not your actual icon than it don’t rotate in place but relatively to the root node center. In your case the top left angle.
Either or. You are rotating the parent, and the child, which is the one visible, has inherited the position. So either rotate the child or make the parent the only thing, give it the icon texture, etc.