Look Script for Cutouts
This script will cause any cut out to turn and face the closest av.
Add Script
Right click on your cut out and choose edit from the pie menu.
Go to the contents tab in the edit menu and click on "New Script."
Open the new script and replace its contents with the following code:
Open the cut-out contents from the edit menu and click on the add script button.
Open the new script.
Paste the following code into the window, replacing the current contents:
//Simple Rotation Script to give your Bartender a little life
//If this script is set to run, it will turn to face the nearest agent.
//Modify to fit your bartender.
//Based off of scripts by Ope Rand & Christopher Omega
// AXIS_* constants, represent the unit vector 1 unit on the specified axis.
vector AXIS_UP = <0,0,1>;
vector AXIS_LEFT = <0,1,0>;
vector AXIS_FWD = <1,0,0>;
rotation getRotToPointAxisAt(vector axis, vector target) {
return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
}
// Strength and damping are values used to control how llRotLookAt and llLookAt move, these values are tunable.
float strength = 1.0;
float damping = 0.250;
default {
state_entry() {
//Stops it from tipping over
llSetStatus(STATUS_ROTATE_X, FALSE);
llSetStatus(STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_ROTATE_Z, TRUE);
//llSensorRepeat(string name, key id, integer type, float range, float arc, float rate)
llSensorRepeat("",NULL_KEY,AGENT,10,PI,1); //set the last three variables lower/higher to lessen lag
}
sensor(integer num_detected) {
vector target = llDetectedPos(0);
// This line points the fwd (X) axis at the target:
llRotLookAt(getRotToPointAxisAt(AXIS_FWD, target), strength, damping);
// This line points the left (Y) axis at the target:
// llRotLookAt(getRotToPointAxisAt(AXIS_LEFT, target), strength, damping);
// This points the up (Z) axis at the target:
// llRotLookAt(getRotToPointAxisAt(AXIS_UP, target), strength, damping);
}
}
Go to the contents tab in the edit menu and click on "New Script."
Open the new script and replace its contents with the following code:
Open the cut-out contents from the edit menu and click on the add script button.
Open the new script.
Paste the following code into the window, replacing the current contents:
//Simple Rotation Script to give your Bartender a little life
//If this script is set to run, it will turn to face the nearest agent.
//Modify to fit your bartender.
//Based off of scripts by Ope Rand & Christopher Omega
// AXIS_* constants, represent the unit vector 1 unit on the specified axis.
vector AXIS_UP = <0,0,1>;
vector AXIS_LEFT = <0,1,0>;
vector AXIS_FWD = <1,0,0>;
rotation getRotToPointAxisAt(vector axis, vector target) {
return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
}
// Strength and damping are values used to control how llRotLookAt and llLookAt move, these values are tunable.
float strength = 1.0;
float damping = 0.250;
default {
state_entry() {
//Stops it from tipping over
llSetStatus(STATUS_ROTATE_X, FALSE);
llSetStatus(STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_ROTATE_Z, TRUE);
//llSensorRepeat(string name, key id, integer type, float range, float arc, float rate)
llSensorRepeat("",NULL_KEY,AGENT,10,PI,1); //set the last three variables lower/higher to lessen lag
}
sensor(integer num_detected) {
vector target = llDetectedPos(0);
// This line points the fwd (X) axis at the target:
llRotLookAt(getRotToPointAxisAt(AXIS_FWD, target), strength, damping);
// This line points the left (Y) axis at the target:
// llRotLookAt(getRotToPointAxisAt(AXIS_LEFT, target), strength, damping);
// This points the up (Z) axis at the target:
// llRotLookAt(getRotToPointAxisAt(AXIS_UP, target), strength, damping);
}
}
Compile and Run Script
Save the script. Hopefully the cutout will turn to face you... if not we need to tweak the script.
Tweak If Necesary
If you need to tweak it:
Set the ruler mode to local while selecting your cut out. See which directions it's axes are pointed. By default the script points the positive x-axis at you. You may need to uncomment a portion of the code (a line begining with llRotLookAt) by removing the double slashes infront of a line and comment out another portion of the code (all other llRotLookAt lines) by adding double slashes. You might also have to change the true/false values to allow the cut-out to turn.
Also you can change the sensor values to reduce lag.
Set the ruler mode to local while selecting your cut out. See which directions it's axes are pointed. By default the script points the positive x-axis at you. You may need to uncomment a portion of the code (a line begining with llRotLookAt) by removing the double slashes infront of a line and comment out another portion of the code (all other llRotLookAt lines) by adding double slashes. You might also have to change the true/false values to allow the cut-out to turn.
Also you can change the sensor values to reduce lag.