How can you allow the player to use Vertex Snapping in order for them to build a vehicle.

I need some documentation on this. Even if you can show me a simple code by example I can figure this out. So far I have looked into mathf but I am stuck.

Could you maybe create custom “joints” which you could use to attach these parts together on?

If not, i recentrly did something similar myself.

-I used raycast to assign an object to a lastHoveredObject varible.
-Then it stores all vertices of that objects mesh to an array I keep reseting as I get new targets.
-I also converted all the vertices in the array to screenposition and then iterated through them all to check if they were touching my invisible rectangle near my mouse, and chose the closest vertex and placed a GUITexture on it.
-It then stored that worldposition (Vertex) as a Vector3 varible i used to place an element there.

Don’t have the code I used here I’m afraid, but should get you started!

I did this for a sorta Lego game. What I did was assign ‘snap points’ (empty game objects) as children of the object. Then a script converts the location of those snap points to world coords. As the mouse position (ray casted into the scene) is a minimum distance from any snap point, the dragged part snaps there. Use the snap point’s transform and possibly a snap point on the dragged object to align the parts x,y,z, and have fun with the rotations lining up (a bit trickier but doable).

If you really just need the vertices on a mesh, then you can create an array of vertices and TransformPoint the mesh’s verts into it to have a handy list of world-space points to look through.