Whats a fast way to get things within an area while supporting different sized parts?

Recently, I’ve been trying to make a voxel destruction system using a method i saw on a post, it has gone well so far, but I’ve been adding combination logic that combines parts closeby. To do this, I needed to find parts that were next to eachother. I did this via raycasts and that worked fine, until the hitboxes got big, where i’d get a good 1-2s freezes. I’ve been debugging it and optimising parts and now i’ve gotten to what I believe is the biggest performance sinkhole. Basically, I’m cloning a lot of parts, and then parenting them to workspace (so I can raycast with them) and then destroying them / returning them to cache which basically makes the entire ‘cloning’ part wasteful. I want to basically have a custom raycast method that I can use with things that arent parented under the workspace. I’ve looked into things like octrees and spatial hashes but they’re missing a size parameter and they’re slower than raycasting, so what’d be a good way to do this? (Also, please dont ask me how the system works, its really stupid but it manages to somehow work :sob: )

2 Likes