How does editable meshes work, and how would i deform them if a player touches it (something like snow.) I swear i tried to learn how to use them but i cant.
How editable meshes work is by creating a blank or modifying an already made mesh (has restrictions) which in summary allows you to create verticies, apply triangles, normals, UV, colors, etc. Roblox’s Editable Mesh Library
This post does a great job showcasing the mesh and image API:
Mesh & Image APIs Forum
Here’s the usual format of creating editable meshes:
local assetService = game:GetService("AssetService")
local editable = assetService:CreateEditableMesh()
--extend code
local mesh = assetService:CreateMeshPartAsync(Content.fromObject(editable)
mesh.Parent = workspace --location
When it comes to the idea you had where you can “deform” a mesh whenever a player touches it. The touch itself it pretty simple with mesh.Touched:Connect(function(obj))
then doing mesh:RaycastLocal(p: Vector3). However the idea of deforming a mesh would require finding potential verticies (replicated to world space) intersecting an object’s region (using :FindClosestPointOnSurface(), :FindClosestVertex(), or :FindVerticesWithinSphere()) then either adjusting/adding verticies based on the surface of said region in order to keep (for example) footsteps parallel to each other.
Another example would be carving a sphere out of any mesh by taking the vertices intersecting the sphere then push then relative to their position, center of sphere, radius, etc. Connecting and possibly creating new triangles to outline without massively ruining the structure of the region’s triangles.
Due to the high complexity there are unionasync APIs you could use instead for deformation however removes the whole mesh idea.
May I also question what you’re planning on using mesh deformation for? It sounds very interesting and computationally intensive.
its difficult. I just learned the basics. Here is a really nice video though that helped me out a lot: https://www.youtube.com/watch?v=HKr6ljJQ1Tw
That actually helped me a lot understand how editable meshes work, thanks! I’m planning to use a deformable snow system for a first person horror game I’m making.
Thanks! I’m definitely going to watch it!
Thanks everyone that replied to this post, I was able to make it and optimize to not be performance intensive, that means that if I implement LODs i will be able to insert it on most parts of my map!