GetEngineCameraPosition

Definition

double,double,double GetEngineCameraPosition(string engineCameraName)

Description

This function returns the 3D position of engine camera engineCameraName.

Parameters

engineCameraName
Specifies the name of the engine camera. You can also use the name “this” for this parameter. In this case, “this” refers to the camera object that this script is attached to.

Return Value

This function returns the 3D position of engine camera engineCameraName as three values x, y, z.

Example 1

pos_x = 0.0
pos_y = 0.0
pos_z = 0.0

function Init()
    pos_x, pos_y, pos_z = GetEngineCameraPosition("camera1")

    message = string.format("\nCamera position is > (%.2f, %.2f, %.2f)" , pos_x, pos_y, pos_z)
    PrintConsole(message)
end

function Update()

end
Returns the 3D position of the “camera1” engine camera.

Example 2

--name of script is GetEngineCameraPosition2.lua

pos_x = 0.0
pos_y = 0.0
pos_z = 0.0

function Init()
    pos_x, pos_y, pos_z = GetEngineCameraPosition("this")

    message = string.format("\nCamera position is > (%.2f, %.2f, %.2f)" , pos_x, pos_y, pos_z)
    PrintConsole(message)
end

function Update()

end
In this case, “this” string in the GetEngineCameraPosition points to the engine camera that GetEngineCameraPosition2.lua script is attached to. For example, if GetEngineCameraPosition2.lua script is attached to a engine camera named “camera1”, “this” will be equivalent to the name “camera1”. In this example, GetEngineCameraPosition function returns the 3D position of current engine camera.
adminGetEngineCameraPosition