Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Make an object look at you?

Nickolus Lufbery
Registered User
Join date: 14 Oct 2006
Posts: 25
10-02-2008 23:29
I have seen people with objects that look at the nearest person, browsed the entire library and couldn't find one for it, anyone have of these laying around?
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
10-03-2008 02:34
you can have this:
CODE

default
{
state_entry()
{
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSensorRepeat("",llGetOwner(),AGENT,96.0,PI,1.0);
}
sensor(integer Number)
{
vector position=llDetectedPos(0);
vector Offset=< -1.0, 0.0, 1.5>;
position+=Offset;
llSetStatus(STATUS_PHYSICS, TRUE);
llMoveToTarget(position,0.4);
llLookAt(llDetectedPos(0)+<0.0, 0.0, 1.0>,0.5,0.5);
}
}

It will follow you and point the prim's Z-axis to you (you are the owner)
To make it look at the nearest person replace llGetOwner with NULL_KEY and find out wich agent is closest in the sensor event handler.
Happy scripting:)
_____________________
From Studio Dora
Victor Reisman
Smithy of SL
Join date: 5 May 2006
Posts: 18
10-07-2008 12:22
I found this very useful, however, how would I make the object point on its X axis instead of the Z axis, (and its not working by changing <0.0,0.0,1.0> to <1.0,0.0,0.0>;). Thanks in advance.
_____________________
Stylize, Revolutionize, Whatever your game is, Second Life is a new world with unlimited potential, and I intend to push the unlimited.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-07-2008 12:32
i think you can do that with llRotLookAt



otherwise, you can make the root prim invisible,and rotate the rest of the object to fix it
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Victor Reisman
Smithy of SL
Join date: 5 May 2006
Posts: 18
10-07-2008 14:01
unfortunately, llRotLookAt needs a rotation to look at, not a position. Unless there's some way to convert my position to a rotation, I'm at a complete loss.
_____________________
Stylize, Revolutionize, Whatever your game is, Second Life is a new world with unlimited potential, and I intend to push the unlimited.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-07-2008 14:12
Try what Ruthven suggested in post #4 or just create another prim, rotate z axis in the direction you want in regard to the rest of the build, make it invisible if necessary and make it the root prim when you link it together. With the script in the new root prim, the object will turn correctly.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
10-07-2008 20:02
CODE

default
{
state_entry()
{
llSensorRepeat("", "", AGENT, 96.0, PI, 0.5);
}

sensor(integer number)
{
vector direction = llVecNorm(llDetectedPos(0) - llGetPos());
rotation fwd = llRotBetween(<1.0, 0.0, 0.0>, direction);
llRotLookAt(fwd, 1.0, 1.0);
}
}


Something like that should work, although I can't guarantee it will compile, since I wrote it in the reply window.
_____________________