How do I make sure these voxels are in the correct positions based on their size?

I’m making a little thing that converts smooth terrain into parts, but I have a problem with the differing sizes of the voxels causes gaps and I’m not sure how to fix this.


What is it supposed to look like?

for each voxel, make a raycast going up, down, left, right, forward, backward

if you have a table of voxels then you can instead use that for better performance, and then use the position plus the size vector rotated towards the current voxel to get the surface point

for each of these raycasts, if hit, add the difference between raycast.Position and voxel.Position to voxel.Position – so that this voxel can attach to multiple neighboring voxels on the corners

1 Like

could u pls explain what this means?

this what my interpretation of what u said


do it for the other three directions too; you can get them by multiplying right up and lookvectors by -1

you probably have to play around with it alot to make it look good
maybe when only forwards and backwards or left and right hit you can scale the part instead because moving won’t fill in the holes in that case

1 Like

Size or reposition the part to connect with parts next to it. You don’t need raycasts for this since you already have the information needed to calculate the bounds (check X, Y, and Z ±1).

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.