Step 1Add Script
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);
}
}
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|



































