Hi! I’m trying to use Sprite2D’s region in a script so i could make a looping background, idk if it is even possible but got curious if it would work that way :'D
it gives me this error "Invalid operands ‘Rect2’ and ‘Rect2’ in operator ‘+’.
if this isn’t the way to go in making a loopable background with sprite2d then i would appreciate some advice with it, since i’m still in the big learning process with GDScript and Godot tbw
edit: with loopable moving background im trying to go with the yume nikki style / other RPGMaker games
I use shaders to apply loopable backgrounds when I need, easy as set the ShaderMaterial on the Sprite, TextureRect, ColorRect and I can change the parameters without any effort:
// https://lucassaturn.co.uk/dev/godot/texture_scroll.html
shader_type canvas_item; //set type of object it applies to
uniform vec2 direction; //x and y direction
uniform float speed; //speed value
varying vec4 modulate; //grab colours after modulate/self-modulate
void vertex(){ //applies to every single vertex
modulate = COLOR;
}
void fragment(){ //applies to every single pixel
vec2 move = direction * TIME * speed; //create offset
COLOR = texture(TEXTURE, UV+move) * modulate; //set colour
}