Skip to content

GetFacing

The GetFacing function retrieves the current facing direction of a specified unit or object in radians. This function is useful for determining the orientation of units or objects in the game world, which can be important for navigation, targeting, and other gameplay mechanics.

Parameters

  • unit: The unit identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) for which to retrieve the facing direction.

Returns

  • facing: A numeric value representing the facing direction of the specified unit or object in radians.

Example Usage in Lua

Here is an example of how to use the GetFacing function in Lua:

local api = ...

-- Function to print the facing direction of the player in radians
function PrintPlayerFacing()
    local player = "player"
    local facing = api.GetFacing(player)
    print("Player's facing direction: " .. facing .. " radians")
end

-- Function to print the facing direction of the target in radians
function PrintTargetFacing()
    local target = "target"
    local facing = api.GetFacing(target)
    print("Target's facing direction: " .. facing .. " radians")
end

-- Function to print the facing direction of a specific unit by GUID in radians
function PrintUnitFacingByGUID(unitGUID)
    local facing = api.GetFacing(unitGUID)
    print("Unit with GUID " .. unitGUID .. "'s facing direction: " .. facing .. " radians")
end

-- Call the functions
PrintPlayerFacing()
PrintTargetFacing()

-- Example unit GUID (replace with an actual GUID in your game)
local exampleUnitGUID = "1234-5678-9012-3456"
PrintUnitFacingByGUID(exampleUnitGUID)