So for hitboxes of custom shapes, I’m creating BaseParts which are stored in ReplicatedStorage, Cloning them into workspace, and running :GetTouchinParts() before removing the hitbox clone.
How computationally expensive is this in comparison to other options - and what are those other options?
What is your need for using the conical hitboxes, out of curiosity?
If you absolutely need that then using Roblox’s collisions is probably your best bet. I would use this sparingly though, or at the very least don’t use it in conjunction with the .Touched event. The touched event fires every frame if either of the two objects in the collision have moved.
I need to be able to calculate what parts are entirely illuminated by a SpotLight, and the simplest way I’ve found is to generate a part from the SpotLight’s properties and use this
It’s relatively expensive. I’ll use this technique for one-off events, like explosions or validation on click.
You can do it once or twice per a frame in my experience if you really need to. If you’re doing it more than that you might want to find a new technique.
Note a decent amount of my expected cost of this operation is the cost of cloning a part and parenting it. You might save some cost by deleting it the same frame.
I would suggest that you already have the part on the tool and instead Connect and disconnect the event when you need to. Cloning is likely more expensive.
That sounds like about what I expected - is there any way to run code before the next frame is rendered, but only once? i.e. without it running every frame
Maybe something like
function coneCheck()
-- Cone checking stuff
RunService:UnbindFromRenderStep("cone") -- Meaning it only runs one frame
end
TriggeringEvent:Connect(function()
RunService:BindToRenderStep("cone", 1, coneCheck)
end)