繁体   English   中英

如何获得两个物体之间的距离? (LUA)

[英]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)

如何获得“我”和“目标”之间的距离? 我尝试了一切..:/

https://developer.roblox.com/articles/Magnitude这就是它在Wiki上所说的,这是一个范例:

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

print(distance)将返回距离(以int / float之类的值表示)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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