Skip to content

llGetRootPosition

vector llGetRootPosition()

Returns the position (in region coordinates) of the root prim of the object which the script is attached to.

This is used to allow a child prim to determine where the root is.

This example demonstrates how to determine if a script is running in the root prim or a child prim:

default {
touch_start(integer vIntTouched) {
string vStrMessage = "The prim with this script is ";
if (llGetPos() != llGetRootPosition()) {
vStrMessage += "NOT ";
}
llSay(PUBLIC_CHANNEL, vStrMessage + "centered on the root prim.");
}
}

Since there is no llSetLocalPos function, this helper adds functionality to match llGetLocalPos() in a child prim:

fSetLocalPos(vector vPosOffset) {
llSetPos(llGetRootPosition() + vPosOffset);
}
// This will move a root prim by the offset, or set the
// position of a child prim relative to the root.