- Home /
Raycasting to the polygon level.
I'm creating a script that controls a players movements for grabbing onto a ledge, and climbing up onto or over it. I have come up with multiple equations to determine if the triangles that make up the edge of a mesh are the right slope and area in order for the player to be able to grab or climb up them. So the question is: is it possible to raycast to the individual polygons that make up a mesh and its mesh collider? I need to be able to select a random triangle from a mesh and have its vertices and maybe later access the vertices of adjacent triangles and polygons, but my fear is that unity's access to meshes may be of to high a level to achieve this goal.
Any help would be appreciated, -Malarkey
Answer by SirMalarkey · Jul 03, 2014 at 02:57 AM
After enough digging i have found a solution to this problem, The RaycastHit structure returned by Physics.Raycast contains a variable called TriangleIndex which gives you the individual triangle that was hit, the next problem to tackle is obtaining adjacent triangles of the mesh collided with and other meshes close by. I will continue looking into this and post the answer here when I discover it.
Edit: So after some more research and talking with a few knowledgeable people I have determined that no polygon or triangle in Unity has any connection to any of the other polygons around or adjacent to it. The only way to determine if two polygons are adjacent is to compare all of the vertices of their mesh or meshes to see it any match. This is a major blow to the development of my free running based game, but i have started to come up with a number of solutions to this issue ranging from sorting methods to a more effective modeling workflow. In the future I will be creating a forum to document my progress.