3D ray tracing using raycast

Honestly I just ask because almost every time I ask ChatGPT to make something in craft it assumes there’s a raytracing function and it would be great to just give it one instead of watching it make the same mistake repeatedly.

Right now for example I am trying to get it to write something that will let me manually draw directly on the craft models, but it can’t figure out how to tell where I’m touching the models.

i think you can use physics:raycast. If it hits a rigidbody it gives you the point on the surface and the normal at that point.

Do you know how it handles submeshes?

@UberGoober the raycast works with physics rigid bodies. You add a rigid body to the 3D model using craft.shape.model. If a 3D model is attached to the rigidbody, in addition to the location where the raycast hit, the raycast will also give back the triangleIndex of the hit triangle and location within the triangle.