// AXIS_* constants, represent the unit vector 1 unit on the specified axis.
vector AXIS_UP = <0,0,0>;
vector AXIS_LEFT = <5,0,-.50>;
vector AXIS_FWD = <0,0,0>;
// getRotToPointAxisAt()
// Gets the rotation to point the specified axis at the specified position.
// @param axis The axis to point. Easiest to just use an AXIS_* constant.
// @param target The target, in region-local coordinates, to point the axis at.
// @return The rotation necessary to point axis at target.
// Created by Ope Rand, modifyed by Christopher Omega
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 = 1.0;
default
{
state_entry()
{
llSay(0, "Ready For Operation"
;}
link_message(integer sender, integer num, string msg, key id)
{
if (num == 89769)
{
llSensorRepeat( "", "",AGENT,96, PI,0.2);
}
if (num == 98769)
{
llSensorRemove();
llSetText("",<1,1,1>,1);
}
}
sensor(integer sense)
{
vector target = llDetectedPos(0); // A vector to look at.
// These two lines are equivalent, and point the up (Z) axis at the target:
llRotLookAt(getRotToPointAxisAt(AXIS_UP, target), strength, damping);
llLookAt(target, strength, damping);
// 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);
llSetText("Tracking:" + llDetectedName(0),<1,1,1>,1);
}
no_sensor()
{
}
}
