Before any replies, I won’t be trying to use any public module like Zones in a preference to create my own approach that I can customize to my specific need, I can potentially make it even more efficient depending on my use case.
I want to create a custom touched system for a group of objects much like the Zones module does and my objects are particularly circle objects.
There are flaws to doing the Touched
and GetTouchingParts
method that are great enough I want to do alternative approaches. I definitely can’t do magnitude calculation or only Region3 since I am using circular multiple objects.
So, I am trying to do it exactly how the Zone module states they do it, however, I am stuck at the raycast part.
Here is my proposed way of the raycasting method where I try to get the exact ground level the player is on then add 0.5 studs then shoot downward by a unit vector.
local function getObjectBelow(character)
local humanoid = character.Humanoid
local hrp = humanoid.RootPart
local ray = Ray.new(hrp.Position - Vector3.new(0, hrp.Size.Y/2, 0) - humanoid.HipHeight + 0.5, -hrp.UpVector)
return workspace:FindPartOnRay(ray, character) -- ignore character
end
I know about RaycastParams but for now I just had this before I knew about it so I’ll convert it to RaycastParams API use myself from what is given now.
Is this a good way to go about it or can/should I use a different approach?