# Camera Distance of Player

Grammar — Current camera distance of player player
FlagsNative | Function

Returns the current camera distance of a player. Camera distance is tracked for all players in a multiplayer game, but the queried locations will be slightly old due to network latency.

# Arguments

  • int — Player

Returns — fixed

native fixed CameraGetDistance(int player);

Category: Camera / Basic

# Examples

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignMissionLib.galaxy:4832


    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignMissionLib.galaxy:4833

    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
    lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

mods/novastoryassets.sc2modbase3.sc2maps/maps/campaign/nova/nova09.sc2map/MapScript.galaxy:4632


    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

mods/novastoryassets.sc2modbase3.sc2maps/maps/campaign/nova/nova09.sc2map/MapScript.galaxy:4633

    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
    lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

mods/novastoryassets.sc2mod/base3.sc2maps/maps/campaign/nova/nova09.sc2mapMapScript.galaxy:4632


    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

mods/novastoryassets.sc2mod/base3.sc2maps/maps/campaign/nova/nova09.sc2mapMapScript.galaxy:4633

    lv_cameraPosition[0] = PointGetX(CameraGetTarget(1));
    lv_cameraPosition[1] = (PointGetY(CameraGetTarget(1))-(Cos(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, CameraGetTarget(1))+(Sin(CameraGetPitch(1))*CameraGetDistance(1)));
    lv_effectPosition[0] = PointGetX(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));
    lv_effectPosition[1] = PointGetY(EventPlayerEffectUsedPoint(c_effectLocationTargetPoint));

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:25328

        lv_cameraTargetPoint = CameraGetTarget(lv_player);
        lv_cameraPosition[0] = PointGetX(lv_cameraTargetPoint);
        lv_cameraPosition[1] = (PointGetY(lv_cameraTargetPoint)-(Cos(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
        lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, lv_cameraTargetPoint)+(Sin(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
        lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:25329

        lv_cameraPosition[0] = PointGetX(lv_cameraTargetPoint);
        lv_cameraPosition[1] = (PointGetY(lv_cameraTargetPoint)-(Cos(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
        lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, lv_cameraTargetPoint)+(Sin(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
        lv_distance = SquareRoot((Pow((lv_cameraPosition[0]-lv_effectPosition[0]), 2.0) + Pow((lv_cameraPosition[1]-lv_effectPosition[1]), 2.0) + Pow((lv_cameraPosition[2]-lv_effectPosition[2]), 2.0)));
        CameraShakeStart(lv_player, c_cameraPositionTarget, c_cameraDirectionZ, MaxF((1-(lv_distance/50)), 0.0), 5.0, 100.0, 0.5);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:29243

    lv_cameraTargetPoint = CameraGetTarget(lv_player);
    lv_cameraPosition[0] = PointGetX(lv_cameraTargetPoint);
    lv_cameraPosition[1] = (PointGetY(lv_cameraTargetPoint)-(Cos(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, lv_cameraTargetPoint)+(Sin(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
    lv_effectPosition[0] = PointGetX(lv_effectTargetPoint);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:29244

    lv_cameraPosition[0] = PointGetX(lv_cameraTargetPoint);
    lv_cameraPosition[1] = (PointGetY(lv_cameraTargetPoint)-(Cos(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
    lv_cameraPosition[2] = (WorldHeight(c_heightMapGround, lv_cameraTargetPoint)+(Sin(CameraGetPitch(lv_player))*CameraGetDistance(lv_player)));
    lv_effectPosition[0] = PointGetX(lv_effectTargetPoint);
    lv_effectPosition[1] = PointGetY(lv_effectTargetPoint);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:33863

        lv_indexPlayer = PlayerGroupNextPlayer(auto3DF840ED_g, lv_indexPlayer);
        if (lv_indexPlayer < 0) { break; }
        lv_originalDistance = CameraGetDistance(lv_indexPlayer);
        CameraSetValue(lv_indexPlayer, c_cameraValueDistance, (lv_originalDistance+8.0), 0.0, -1, 10.0);
        CameraSetValue(lv_indexPlayer, c_cameraValueDistance, lv_originalDistance, 1.5, -1, 10.0);