Hello! its me again. i am wondering what would be the best way for me to detect if a raycast is within a voxel? a great example of what i am trying to achieve is the block breaking in Minecraft
Index the âMaterialâ key/field of the returned âRaycastResultâ value. If the casted ray hit a BasePart the value assigned to this key/field would describe the BasePartâs material (what material enumeration is assigned to its âMaterialâ property). Alternatively, if the casted ray hit a Terrain cell the value assigned to the key/field would describe the Terrain cellâs material and is largely dependent/reliant on the Terrain itself.
No not what I mean I already know how the raycast API works. That wonât be able to work since I am planning of using greedy mesh to optimize it
A few questions I have:
- Are you using custom terrain, like blocks? Or is it Roblox terrain.
- Did you already create the terrain generation script?
Itâs gonna use parts, and no I didnât start working on the terrain script yet since i want to figure out this first
I think youâll have to create the terrain generation first before solving this issue. Once youâve created a terrain generation script, you will be able to determine what block is in a specific âposition.â
After raycasting (and this is after youâve implemented the greedy mesh system) you will get RaycastResult.Position and RaycastResult.Instance. You can use the Instance part to determine what greedy mesh section you got and you can use the Position part to determine what block is most likely to be the block they hit.
Use all 3 things Iâve talked about and youâll develop a failproof way of determining what block the player hit.
Damn thanks man this might work