Created
January 1, 2020 02:51
-
-
Save OverHash/f4ad76d5668d1ded1b5ed66e9a98325c to your computer and use it in GitHub Desktop.
A test to see what method is the fastest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- OverHash method: https://devforum.roblox.com/t/detecting-on-which-map-the-character-is/233463/13?u=overhash | |
-- Aznarog method: https://devforum.roblox.com/t/what-is-the-quickest-and-most-efficient-way-to-check-if-a-player-is-within-a-region/367554/5?u=overhash | |
-- EDmaster24 method: https://devforum.roblox.com/t/what-is-the-quickest-and-most-efficient-way-to-check-if-a-player-is-within-a-region/367554/3?u=overhash | |
-- ForeverHD method: https://devforum.roblox.com/t/zonecontroller-retrieving-players-within-an-area-zone/397465 | |
local Functions = { } | |
local hitbox, part = workspace.Model.MAIN, workspace.Model.example | |
Functions["OverHash method"] = function() | |
local LocalDifference = (hitbox.CFrame - hitbox.CFrame.p):inverse() * (part.Position - hitbox.Position) | |
local inRegion = ((math.abs(LocalDifference.X) < hitbox.Size.X/2) and (math.abs(LocalDifference.Z) < hitbox.Size.Z/2)) | |
end | |
Functions["Aznarog method"] = function() | |
local size = part.Size | |
local partCFrame = part.CFrame | |
local max = partCFrame.p + (0.5 * size) | |
local min = partCFrame.p - (0.5 * size) | |
local region = Region3.new(min, max) | |
local relativePosition = (hitbox.Position - region.CFrame.p) / region.Size | |
local inRegion = not(-0.5 <= relativePosition.X and relativePosition.X <= 0.5 | |
and -0.5 <= relativePosition.Y and relativePosition.Y <= 0.5 | |
and -0.5 <= relativePosition.Z and relativePosition.Z <= 0.5) | |
end | |
local zone = require(script.Parent.ZoneController).new(part, 10, false) | |
Functions['ForeverHD'] = function() | |
local inRegion = zone:getPlayer(hitbox) | |
end | |
local RotatedRegion3 = require(script.Parent.RotatedRegion3) | |
Functions['EDmaster24 method'] = function() | |
local region = RotatedRegion3.fromPart(hitbox) | |
local inRegion = region:castPart(part) | |
end | |
wait(5) | |
for i = 1, 5 do | |
require(2110831719).new(2, "Region3 vs math", Functions) | |
wait(3) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment