簡體   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