Don't click here unless you want to be banned.

LSL Wiki : llGetAgentSize

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
vector llGetAgentSize(key id)

If id is in the same sim region as the script calling this function, it returns a vector representing the size of the avatar. This is useful for approximating the height of the avatar. This function returns a ZERO_VECTOR when the key is not an agent or the agent is not in the sim.

The returned vector holds the size of the avatar's bounding box (*), of which only the height (z) varies. Width (x) and depth (y) are constant. (0.45m and 0.6m respectively). While the size returned by this function does not change when the avatar sits down (whether on an object or on the ground), the bounding box returned by llGetBoundingBox will change its size to include the object the avatar is sitting on.

(*) The returned value is NOT in meters. To get the actual avatar height (counting shoes, and with a +/-3cm precision) you need to apply a factor of 1.125 (you can test this by changing a prim with llSetScale and compare the size).

In the official Second Life viewer, avatar height is not readily available, as such, no consistency has ever developed over avatar height. Some viewers do however report an adjusted value in the Edit Appearance window (avatar->mBodySize.mV[VZ] + 0.17 in Meerkat, Cool VL Viewer, Imprudence, Emerald; avatar->mBodySize.mV[VZ] + 0.195 in Snowglobe; see newview/llfloatercustomize.cpp in each release to verify the current formula in use). avatar->mBodySize.mV[VZ] is the number reported by llGetAgentSize.

An accurate measure of avatar height is best obtained by sizing a phantom prim to the value obtained by one of these adjustment methods and standing within it, then adjusting it to a more exact match; llGetAgentSize itself should never be considered accurate.


Example:
default {
    touch_start(integer num_detected) {
        vector size;
        
        size = llGetAgentSize(llDetectedKey(0));
        float realsize = size.z * 1.125;
        llSay(0, "You are " + (string)realsize + "m tall.");
    }
}

Q: Is there a way to automatically trigger a script when an avatar's size changes?
A: No. To do so, you'll need to use a timer, or some other kind of regular check. This can be laggy.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.
There are 3 comments on this page. [Display comments/form]