Returning a local hit from a raycast

I’m working with a voxel engine (voxity from the asset store), trying to add/remove blocks from a chunk that can move around. The problem I’m having is that the engine uses a grid system that assumes no rotation or movement to add/remove blocks.

I use Raycasts to determine where to alter the chunk. Raycasts return world coordinates, however, and the engine doesn’t account for any kind of rotation causing rotated chunks to be incompatible with world coordinates. The movement issue is easy, but rotations is killing me!

The easiest solution I can think of is if I can get a local point on a mesh via raycasting. I know how to get the point a ray hit or the transform of the object it hit, but these both are in world coords. How can I get a local hit position?

If this isn’t possible, what math would I need to learn to allow chunks to factor rotation in and produce accurate results on their local grids?

I’m currently studying computer science and have a reasonable amount of (novice) experience with c# and programming in general.

The trick is, it’s doesn’t have anything to do with raycasting. The raycast gives you the data, and is done. You can do whatever math you want from there.

The real question, I think, is how to convert a world point into a transform’s local coords. Use transform.InverseTransfromPoint.

This object will hold information about what your ray hit, including the transform, which includes rotational data. Look up some tutorials for raycasting in Unity. I have never worked with voxity though and wouldn’t know if this would work for sure.