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

LSL Wiki : llGetAgentSize

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl805.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.
Comments [Hide comments/form]
I've been running a script that keeps a running average of the bounding box height of everyone I come in contact with in SL. The average height of an avatar in malls and other vending and gambling areas is just shy of 6 feet, and if that's low by 10cm that gives you your 2m.

In less commercial areas, though, the average goes down. Either people put on their "Sunday Best" when they're in public, or the people who pick tall avatars tend to be more into buying stuff.

I wish I could run the script in the welcome area.
-- PersialHebert (2005-11-15 14:05:08)
I have a rather simplified explanation of the shopping mall height:
- shopping malls are more visited by women;
- women in SL have or "like" very long legs;
- other place are "mixed" places.
Sure, research is needed to aprove or disapporve thsi statement.
-- 217-148-242-221.happymany.net (2007-04-14 05:58:06)
This function doesnt seem to work occasionally, particularly if the range to the target is over 65m. More testing is needed. (SL 1.18.3).

My theory about shopping malls and height, is that the height for new avatars is about 2m, and the first thing newbs do is go out and buy stuff (or find free stuff). After a while they might notice they're too tall, and this is probably around the time that they are less interested in stuff, and so dont frequent the malls as much. BTW: My avatar is only around 1.6m (5ft 4in)
-- KeikoRau (2007-10-11 11:47:44)
Attach a comment to this page: