I want to check what vert a player’s foot is touching.
Currently I have this:
function addVert(Position)
local vert = mesh:AddVertex(Position)
return vert
end
function addtTri(v1,v2,v3)
local tri = mesh:AddTriangle(v1,v2,v3)
return tri
end
function setColor(Vert,Tri,Color)
if Vert then
mesh:SetVertexFaceColor(Vert,Tri,Color)
else
mesh:SetFaceColors(Tri,Color)
end
end
function addRandColors(v1,v2,v3,v4,tri1,tri2)
setColor(v1,tri1,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
setColor(v2,tri1,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
setColor(v2,tri2,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
setColor(v3,tri1,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
setColor(v3,tri2,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
setColor(v4,tri2,mesh:AddColor(Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255)),1))
end
function addQuad(Position,Color)
local v1 = addVert(Position)
local v2 = addVert(Position+Vector3.new(0,0,1))
local v3 = addVert(Position+Vector3.new(1,0,0))
local v4 = addVert(Position+Vector3.new(1,0,1))
vertPositions[v1] = Position
vertPositions[v2] = Position+Vector3.new(0,0,1)
vertPositions[v3] = Position+Vector3.new(1,0,0)
vertPositions[v4] = Position+Vector3.new(1,0,1)
local tri1 = addtTri(v1,v2,v3)
local tri2 = addtTri(v2,v4,v3)
--addRandColors(v1,v2,v3,v4,tri1,tri2)
end
function recalculate()
mesh:Destroy()
mesh = as:CreateEditableMesh()
local i = 0
for z=0,configsGlobal['Y'],1 do
for x=0,configsGlobal['X'],1 do
addQuad(Vector3.new(x,0,z))
i+=1
end
end
--game:GetService('LogService'):ClearOutput()
print(i)
mesh:MergeVertices(0.01)
local success, errorMessage = pcall(function()
buffer = as:CreateMeshPartAsync(Content.fromObject(mesh))
end)
if not success then
error(errorMessage)
end
meshPart:ApplyMesh(buffer)
w = false
end
It makes a mesh with a size of x,y (Determined by a setting) and I want to know how I would check where the player’s foot is based on the vert location.
This is all to create ripples
If you need more clarification ask!