Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to explain this thing mathematically?

Asked by 6 years ago
Edited 6 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.
so can u like explain to me the script in the link?(credit the link)

--(Assuming the script is within the bullet)

local bullet = script.Parent

bullet.Touched:connect(function(hit) if hit:IsA("Part") then

local sides = {} local sizes = Vector3.new(hit.Size.X,hit.Size.Y,hit.Size.Z) local pos = hit.Position sides[1] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,0,-hit.Size.Z/2))--front sides[2]= pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,0,hit.Size.Z/2))--back sides[3] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(hit.Size.X/2,0,0))--right sides[4] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(-hit.Size.X/2,0,0))--left sides[5] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,hit.Size.Y/2,0))--top sides[6] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,-hit.Size.Y/2,0))--bottom

local ClosestSide = 1 for i,v in ipairs(sides) do if (bullet.Position - v).Magnitude < (bullet.Position - sides[ClosestSide]).Magnitude then ClosestSide = i end end

if ClosestSide == 1 then print("front") elseif ClosestSide == 2 then print("back") elseif ClosestSide == 3 then print("right") elseif ClosestSide == 4 then print("left") elseif ClosestSide == 5 then print("top") elseif ClosestSide == 6 then print("bottom") end end end)


i need to know how to explain this script. pls help

1 answer

Log in to vote
2
Answered by 6 years ago

so can u like explain to me the script in the link?(credit the link)

--(Assuming the script is within the bullet)

local bullet = script.Parent

bullet.Touched:connect(function(hit)
if hit:IsA("Part") then

local sides = {}
local sizes = Vector3.new(hit.Size.X,hit.Size.Y,hit.Size.Z)
local pos = hit.Position
sides[1] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,0,-hit.Size.Z/2))--front
sides[2]= pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,0,hit.Size.Z/2))--back
sides[3] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(hit.Size.X/2,0,0))--right
sides[4] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(-hit.Size.X/2,0,0))--left
sides[5] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,hit.Size.Y/2,0))--top
sides[6] = pos + hit.CFrame:vectorToWorldSpace(Vector3.new(0,-hit.Size.Y/2,0))--bottom

local ClosestSide = 1
for i,v in ipairs(sides) do
if (bullet.Position - v).Magnitude < (bullet.Position - sides[ClosestSide]).Magnitude then
ClosestSide = i
end
end

if ClosestSide == 1 then print("front")
elseif ClosestSide == 2 then print("back")
elseif ClosestSide == 3 then print("right")
elseif ClosestSide == 4 then print("left")
elseif ClosestSide == 5 then print("top")
elseif ClosestSide == 6 then print("bottom")
end
end
end)
0
you could have edited your question... greatneil80 2647 — 6y
0
What you want is basically just everything after line 18, the script basically just determines the closest side and then determines what surface of the part is the closest Synth_o 136 — 6y
0
yeh i think ill do dat TheluaBanana 946 — 6y
0
and no that doesnt help TheluaBanana 946 — 6y
Ad

Answer this question