LSL Wiki Mirror : llGetAgentSize

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
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.

If using this to determine avatar height, remember that the bounding box is not the same as the actual avatar height. Keep in mind that this is an approximation. The actual avatar height can be taller or shorter than the returned measurement based on factors like hair, shoes, avatar height, torso length and leg length. You can eyeball the exact height for a specific avatar with a prim if you need precision.

Avatars in SL tend to be tall. The average is probably around 2 meters.


Example:
default {
    touch_start(integer num_detected) {
        vector size;
        
        size = llGetAgentSize(llDetectedKey(0));
        llSay(0, "You are " + (string)size.z + "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.


Functions | Agent/Avatar
There are 2 comments on this page. [Display comments/form]