How to make a single texture repeat until a certain poit

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kl–k

I want to make this texture repeat itself until a certain coordinate how would I do that

:bust_in_silhouette: Reply From: Blockmaster27

Not sure if this is 2D or 3D but perhaps try looking into tilemaps or using an area node. Otherwise you could do this in one script:

1.) Instance one of the textures at a starting point.
2.) Create a ‘maximum distance’ for each axis. This will be the X, Y, Z coords that the texture stops at.
3.) Create a ‘snapping distance’ for the nodes. This will be the amount that the textures are translated each time they are instanced.
4.) Keep instancing the textures with the Vector2/Vector3 translations of the last added node added by the snapping distance. This will place them evenly.
5.) Add an ‘If’ statement that checks if the instanced node is greater than the maximum distance for each axis.
6.) When the node is past the maximum distance, call queue_free() on the node.

This can all be done cleanly in a for loop but it’s not necessary. Areas would be an easy way to do this if you have trouble with the maximum distance.

I used tile maps as you suggested at the start of your answer and it worked. thanks

kl–k | 2023-01-29 18:02