By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
if ((positionCameraToWorld [0,0,0] distance player)>2) then { hint "3rd person" } else { hint "1st person" };
Command in Camera Control, Positions
Also available as Markdown and JSON, or read the original wiki page.
Get the world coordinate space (AGL) from a camera-relative position.
positionCameraToWorld cameraPos
Parameters:
cameraPos: PositionRelative - relative camera position, format [x, z, y] (X = left-right, Z = below-above, Y = back-front)
Important
This command has Y and Z axes swapped around, which is different from the usual model space coordinates format ([x, y, z]).
Returns: PositionAGL - camera world position
_worldPos = positionCameraToWorld _cameraPos;
Example demonstrating reversed Y and Z:
player setDir 0; // assuming player is looking forward
hint str [positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,1]];
/*
[
[2481.35, 5671.21, 1.51395],
[2481.35, 5672.21, 1.46955]
]
*/
_cameraAGLPosition = positionCameraToWorld [0,0,0];
modelToWorld · modelToWorldVisual · getCameraViewDirection · weaponDirection · eyeDirection · vectorDir · vectorDirVisual
By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:
if ((positionCameraToWorld [0,0,0] distance player)>2) then { hint "3rd person" } else { hint "1st person" };
The camera coordinate system is different from the model coordinate system: when modelToWorld uses [x, y, z] then positionCameraToWorld uses [x, z, y]. So for a steady camera the following is true:
positionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];