#Mining system
1 messages · Page 1 of 1 (latest)
So like you use a part and .Touched or something?
Or are you talking about voxels
find out
Its like each click a 3x3x3 object spawns and when it rouches mineable it decreases health int
just debounce and its fine
I think it's fine, but I'd personally use Spatial Queries like GetPartBoundsInBox (https://create.roblox.com/docs/reference/engine/classes/WorldRoot#GetPartBoundsInBox)
Does the physics matter?
@median silo
It’s expensive
I'd love to see a benchmark between the different methods
I didn't think it'd be much considering this is probably a hit every few seconds or so and not a method in a loop
.Touched is good enough for this, I remember seeing getpartsinbounds in a production game I had was very expensive over time
I've always heard Touched isn't very reliable (not that I've really had issue with it before, but just saying what I've heard)
Perhaps at one point I'll actually try and benchmark that, as it feels important for me to know
lmk too
** You are now Level 10! **
How do you implement a part hitbox with Touched? I don't normally do it that way
I tried doing 100,000 calls all at once with GetPartBoundsInBox, standing in the middle of a bunch of mesh parts
100,000 GetPartBoundsInBox calls took 8.29276960005518 seconds, detecting 21600216 parts or an average of 0.0000829276960005518 seconds & 216.00216 parts per call, or 0.4975661760033109% of a 1/60 frame - Server - test:16
This could be improved with OverlapParams
It's also possible I did this totally wrong lol
With this quick code
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(p: Player)
p.CharacterAdded:Connect(function(c: Model)
wait(10)
local thr = coroutine.create(function()
local t = os.clock()
local parts = 0
for i = 0, 100_000, 1 do
parts += #workspace:GetPartBoundsInBox(c.PrimaryPart.CFrame, Vector3.one * 50)
end
local totalTime = os.clock() - t
local timePerCall = totalTime / 100_000
local secondsPerFrame = 1/60
print(`100,000 GetPartBoundsInBox calls took {totalTime} seconds, detecting {parts} parts or an average of {timePerCall} seconds & {parts / 100_000} parts per call, or {(timePerCall / secondsPerFrame) * 100}% of a 1/60 frame`)
end)
coroutine.resume(thr)
end)
end)
return {}
Hey @stone bridge, terribly sorry for the ping, but you're pretty experienced in this kind of thing, right?
I'm curious what's the best hitbox method in terms of performance?
Nvm I just searched it up, most of them say touched is worse. I’m guessing this is a new developer so prob letting them use touched is better
GetPartsInBound for this kind of hit would be better though
No totally that makes sense, I tend to do the same, trying to keep it simple for newer devs
why me 
Because I just think you're neat
performance is the wrong question here most of the time
the people who say .touched isn't reliable, don't know how to use .touched
which method you'd use depends on the game
performance is irrelevant
I've never had a problem with touched personally
At least for stationary objects