Hi there, wondering whether this is feasible or not. I’m looking to create a planar mesh mouse cursor that conforms (folds) to follow adjacent surface normals. See image and code below to see the start of my logic - the red area being the photoshopped goal.
I can’t imagine how to do this without checking each vertex of the cursor against colliders, starting from the original hit point and radiating out. First problem with this logic is that it’s doing my head in simply considering how to start. Second problem is whether it’s feasible to shoot out that many rays each frame.
Any suggestions on how to proceed would be greatly appreciated.
Well an arbitrary approach is not really easy. You have to create the geometry procedural. The tricky thing is the edge clipping. The easiest approach would be to use MeshCollider for all of the surfaces. That way you get a lot of information from the hit point when you raycast at the object. You get the triangle index you hit as well as the barycentric coordinate of the hit. With those you can create a sub-piece on this triangle. Now you would check if your desired size of your projected plane is larger than the distance from the hitpoint to the 3 edges of the triangle. If it is larger you have to find the neighbor triangle and create the next piece of mesh there.
As i said it’s not easy to get this working with arbitrary gemoetry.
btw: Do you want a linear projection onto the object or should it really be “folded” around the edge so it doesn’t keep it’s original shape?