0
我有一個用Lua語言編寫的名爲「LookAt」的工作函數。
該函數的代碼和邏輯沒有錯誤。
但我相信我們可以簡化數學邏輯。
function LookAt(target)
local origin = Vec3.New(Engine.ClientData.Origin)
local direction = origin - target
Engine.Pitch = math.deg(math.atan(direction.Z, math.sqrt((direction.X^2) + (direction.Y^2))))
Engine.Yaw = math.deg(math.atan(direction.Y, direction.X)) - 180.0
end
'Engine.Yaw = math.deg(math.atan(-direction.Y,-direction.X))' –