简体   繁体   中英

How to get the distance between 2 objects? (LUA)

game:GetService('RunService').RenderStepped:connect(function()
    if ENABLED then
         local lol = game.Workspace.Zombies:GetChildren()
         local me = game.Players.LocalPlayer.Character
         for index, lol in pairs(lol) do
    if lol:IsA("Model") then
    local AIM = lol:FindFirstChild(_G.AIM_AT)
    if AIM then
    CC.CoordinateFrame = CFrame.new(CC.CoordinateFrame.p, AIM.CFrame.p)
         end
end
end
end
end
end)

How to get the distance between "me" and "AIM"? I've tried everthing.. :/

https://developer.roblox.com/articles/Magnitude This is what it says on the wiki, Here is an Exmaple:

local distance = (part1.Position - part2.Position).magnitude

print(distance) would return the distance (as a value such as int/float)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM