-
What do you want to achieve?
I am trying to tile a texture over an editable mesh grid using GetUVs and SetUV. -
What is the issue?
The texture tiles correctly over certain sections of the mesh, but is stretched weirdly in several rows/columns. -
What solutions have you tried so far?
I have tried debugging with print statements but could not find anything that points to why this could be happening. I do not fully understand how UVs work on editable meshes and there is not much documentation regarding UVs so I am most likely doing something wrong. Should I be setting the UV position to something other than Vector2.new(x, y)?
Here is my code for updating the UVs:
local vertices = {} -- 2D array: vertices[x][y] = vertex_id
RunService.Heartbeat:Connect(function(dt)
local uvs = TestOceanMesh:GetUVs()
local k = 1
for x, _y in vertices do
for y, vertexId in _y do
TestOceanMesh:SetUV(uvs[k], Vector2.new(x, y))
k += 1
end
end
end)
NOTE: The vertices 2D array holds 400 vertices ranging from x=1, y=1 to x=20, y=20.
Here is an image of what is happening (the texture is displayed on the left):