rotation llDetectedRot(integer number)
Returns the
rotation of
detected object or
agent number. (Returns
ZERO_ROTATION (
<0,0,0,1>) if
number is not a valid
sensed object.)
Agents that are
not in
mouselook can only turn around the
world Z-
axis (unless click-dragging the mouse cursor on the
avatar), while those that are in mouselook can rotate in all three directions (the rotation returned here is actually that of the head, i.e. where the avatar is facing). This makes it possible to usually determine if a
user is in mouselook or not (the chance that a user manages to look straight and level in mouselook is pretty small).
Example:
// determine if someone is in mouselook or not
// this method is incorrectly reporting someone to be out of mouselook when they
// reset their camera by pressing escape, then enter mouselook and hold their mouse still
default {
state_entry() {
llSensorRepeat("", llGetOwner(), AGENT, 50.0, PI, 0.5); // sensor for the scripts owner
}
sensor(integer num_detected) {
rotation rot = llDetectedRot(0); // the owner's rotation
if (llVecMag(<rot.x, rot.y, 0>) > 0.001) {
// yup, we're in mouselook
llSetColor(<0, 0, 1>, ALL_SIDES);
} else {
// nope, not in mouselook
llSetColor(<1, 1, 1>, ALL_SIDES);
}
}
}
Note:
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions |
Detection Functions |
Sensors |
Mouselook