Can Move Icon in a Circle, but Can't Rotate it in Place

Godot Version

4.2

Question

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

Could you provide a zipped version of your project? It’s hard to tell why it might be doing that just from you script, which looks correct.

Is the sprite centered? The anchor should be in the middle. Check the offsets.

Ok, I have the zipped file, the forum does not let me post it. I’m sorry, I’m very ignorant

centered box is checked, x and y are on 0 px.

Try this service https://send.vis.ee/

I think I found the problem:
image

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.

Ohh, this does not ease my embarrassment, but now I got it, thank you all lol

1 Like