• 2D
  • Sprite pivot point scrolls with texture offset

I'm using a mirrored texture and its region to scroll it along its Y axis infinitely. The problem comes when trying to rotate the scrolling texture. It seems that its pivot point scrolls along with the texture. As such it gives the impression while testing that the rotation gets faster over time, but this is only the result of the pivot being continuously offset more and more.

My question is, seeing as the sprite node doesn't seem to have access to any pivot property, or set_pivot function, how would I go about updating the pivot, or at least, see to it that it is not being offset along with the texture.

Thank you

Godot version 3.2.1

I’m not sure if this would help or not, but you could try using a TextureRect node instead of a Sprite. You can combine Control-based nodes and Node2D-based nodes.

The positioning sometimes is a little tricky when using Node2D nodes as children of Control-based nodes but using Control-based nodes with Node2D nodes doesn’t have any positioning quirks (that I remember at least). If you use a TextureRect node, then you should be able to access the pivot offset property :smile:

Edit: Also, you can use a shader to across the texture by changing the UV by TIME. I’m away from my machine right now, but a shader like this should work:

shader_type canvas_item;
uniform float scroll_speed = 0.2;
void fragment() {
	COLOR = texture(TEXTURE, UV + vec2(TIME * scroll_speed, TIME * scroll_speed));
}

Infinite scrolling with a TextureRect would need to be done with a material shader or parallaxBG/Layer, correct?

I think you can define the texture region with a TextureRect, but I'm not sure right off. If not, then you may need to use a shader-based solution, in which case I'd recommend seeing if you can use the shader on the Sprite.

I do not think you'd need to use a parallaxBG or CanvasLayer node.

Trying out the shader , scrolling works just as fine, as it did previously, but again, over time, rotation pivot scrolls out following with the texture. Here is what the scene tree and code look like (I reverted back from using the shader, since the problem still occurs.

I think I understand the problem, the pivot is getting offset from the center, which will mess up the math. But I'm not sure exactly how to do this in Godot or what is wrong. Can you share your project? I could probably fix it in a few minutes if I can edit the project.

I spent a few hours today with this and could not get it working. I believe there is some bug with Godot since I can change the position/rotation in the editor manually and it works like expected, but on the running game the offset gets messed up. I tried just about everything, at this point I think it's a bug with the engine.

This is disappointing news, how would I go about submitting a bug report for this? Also, I very much appreciate your time and effort. Thanks again

@NorthProse11 said: This is disappointing news, how would I go about submitting a bug report for this? ...

You can make an issue on the Godot engine GitHub repository. :smile: Normally I'd say to search to make sure the issue is not already been reported, but I searched and I do not see any issues already open for this.