Skip to content
lsl.devlsl.devLSL Dev

LlGetAgentSize

Looking for the current API? Open the llGetAgentSize reference →

Function notes

ZERO_VECTOR is returned if avatar is not in the region or if it is not an avatar.

Return value notes

Returns a vector that is an estimated size of the requested avatar.

Caveats

  • The returned vector is an estimate calculated from the avatar's current shape including shoes. x is a constant 0.45SourceLink/github: {{SourceLink/github|viewer|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=88|text=const F32 DEFAULT_AGENT_DEPTH = 0.45f;}}, y is a constant 0.60SourceLink/github: {{SourceLink/github|viewer|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=92|text=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}, z is the approximate total height of all avatar's bones, with an arbitrary amount added or subtracted based on the current shape's "Hover" setting. Reported height is constrained to the range 1.1 to 2.45 meters, and does not include animation or mesh bone offsets. llGetAgentSize returns the same value as SourceLink/github: {{SourceLink/github|viewer|indra/llappearance/llavatarappearance.cpp|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=433|text=LLVOAvatar::computeBodySize()}}. See SourceLink/github: {{SourceLink/github|viewer|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=86|text=indra/llcommon/indra_constants.h}} for defaults and limits.
    • Due to the shape Hover setting, and mesh and animation offsets, it is not possible to use this function to determine the rendered height of an avatar with any degree of confidence.
  • As of Second Life Server 13.11.19.284082, the return value is the avatar's reported bounding box - <0.1, 0.1, 0.2> when standing. (Avatar bounding boxes have historically been redefined with major physics upgrades.) An avatar's bounding box changes when an avatar sits, while llGetAgentSize is constant for as long as the shape does not change.

Examples

//A simple script that makes a box hover above the owner's head.
default
{
    state_entry()
    {
        key    owner = llGetOwner();
        vector pos   = llList2Vector(llGetObjectDetails(owner, [OBJECT_POS]), 0);
        vector agent = llGetAgentSize(owner);

    //  "pos" needs to be adjusted so it appears above the owner.
        pos.z += 0.5 + agent.z / 2;

    //  makes sure it found the owner, a zero vector evaluates as false
        if(agent)
            llSetPos(pos);
    }

    touch_start(integer num)
    {
        llResetScript();
    }
}

Notes

  • This function is a good way to quickly test...
    • if an avatar is in the same region.
    • if a UUID known to be in the region is an avatar.
To use this function to test either case use as follows
if(llGetAgentSize(uuid)) {
    //uuid is an avatar in the region
} else {
    //uuid is not an avatar in the region
}
  • DEFAULT_AGENT_HEIGHT in SourceLink/github: {{SourceLink/github|viewer|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=96|text=indra/llcommon/indra_constants.h}} is 1.9. This will be the z value if an avatar's shape has not loaded yet. It is possible but extremely rare to see a fully loaded avatar with this exact size, so:
vector agentSize = llGetAgentSize(uuid);
if (agentSize.z == 1.9) {
    // avatar is probably Ruthed
}

See also: functions

See also: articles

Shared wiki helpers

The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.

Template:LSL Function/avatar

Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{#if:

{{#vardefine:p_{{{1|none}}}_desc|avatar {{#if:{{{group|}}}|or group}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}{{{region|}}}|that is in the same [[region]] {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region{{Footnote|handle=known}}}}}}}}

{{#vardefine:p_{{{1|none}}}_hover|avatar {{#if:{{{group|}}}|or group}} UUID {{#if:{{{sim|}}}{{{region|}}}|that is in the same region {{#ifeq:{{{sim|}}}{{{region|}}}|known|or is otherwise known to the region}}}}}}

<includeonly>
{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{LSLC|Avatar/As A Parameter||{{#var:lang}}}}}}
}}}}
</includeonly>

}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|p_{{{1|none}}}_desc}}
|-
{{VarPair|p_{{{1|none}}}_hover}}
|}
</noinclude>
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.