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))' –