Need a quick fix to a simple lua function. It's crashing my client and I need someone's help.
Code:
function GroundZ(object)
local oY,oX,oZ = ObjectPosition(object)
local intZ = oZ + 1
while TraceLine(oX,oY,oZ + 3 ,oX,oY,intZ) == nil do
intZ = intZ - 0.5
end
return intZ + 0.5
end
The idea is to find a Z coordinate closest to the ground of an object.TraceLine returns true if 2 points collide. When traceline returns true, it means intZ point is past the ground. Or, perhaps someone has a better way of determining the GROUND COORDINATES OF THE OBJECT'S X,Y. If that still doesn't make sense, imagine a flying object, and I want the coordinates of the ground BENEATH.