Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Object finding compass

Pim Peccable
Registered User
Join date: 26 Dec 2007
Posts: 4
12-30-2007 03:17
I'm trying to make an object that will alter it's rotation to always face a certain object named in the script.
I realize that it's just a variation on the follow script. but am having trouble with the vectors.

Also: if either the finder and the hidden are attached, would this alter anything? (such as global verses local)

Thanks in advance!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-30-2007 03:31
having the pointer attached will pretty much bork it, since there isn't a way to get the attachment rotation offset on an av, it'll act like it's at the av root position (hips) and rotate acordingly
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
12-30-2007 08:59
//getRotToPointAxisAt(vector axis, vector target)... ;
//This procedure makes one prims axis face a target. The rest of the script scans for agents and used the procedure to face the first found agent:

vector axis = <1,0,0> //makes the prims positive X axis look at a target.

rotation getRotToPointAxisAt(vector axis, vector target) {
return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
} //this function makes "axis" of its prim (<1,0,0> for its positive x axis) look at "target" in world coordinates (<128,128,30> for the center of the server).

default
{
state_entry()
{
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,1);
}
sensor(integer total_number)
{
vector target = llDetectedPos(0); //look at thefirst thing that has been detected
llRotLookAt(getRotToPointAxisAt(axis, target), 1, 2);
}
}