|
| 01 Jun 2014 01:53 AM |
| how do i check for each part in a 15-stud radius, i know it uses magnitude but whats the function used to check for everything in the radius? Do i have to get every single part in workspace and check if its in the radius zone? Would that lag? |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Jun 2014 01:57 AM |
Because Region3's don't support "radius" since they are rectangular, not circular.
OP, just loop through all parts (recurse if you have to) and compare. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 02:22 AM |
| can you give me an example of region3 that might help me |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2014 02:35 AM |
local part = game.Workspace.Part local range = 15 PartsInRadius = {}
function CollectDescendants(model) local collected = {model} if model:GetChildren() then for i,v in pairs(model:GetChildren()) do table.insert(collected, v) if v:GetChildren() then CollectDescendants(v) end end end table.remove(collected, part) return collected end
subjects = CollectDescendants(game.Workspace)
for _,obj in pairs(subjects) do if obj:IsA("BasePart") then local dst = (part.CFrame - obj.CFrame).p.magnitude if dst <= magnitude then table.insert(PartsInRadius, obj) end end end
|
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 01 Jun 2014 02:46 AM |
@above Second function, if line: if dst <= magnitude then Change the 'magnitude' to 'range', you used the wrong variable name. |
|
|
| Report Abuse |
|
|