Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Object with an "Eye"

Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-26-2005 20:00
How can I set one of the faces of a prim to rotate to look at an avatar? I can have a script on the avatar tell the object its coordinates if this is necessary. Sorry if this is pretty basic, I don't deal with rotation that often. Any ideas welcome.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-26-2005 20:06
Just read the turret discussion so I guess I'll start with llLookAt(). However, I do not want the whole thing to rotate toward the av, just on one dimension (i.e. I don't want it to look up if the av is flying, just rotate itself to where the av would be if he/she were right next to it.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
06-27-2005 09:15
Douglas,

My guess is that you're gonna need llLookAt() along with llSetStatus. Disabling the X & Y axis', like so:

llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
_____________________
----------------------------------------------------------
--The mind's eye is limited only by its focus--
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-27-2005 15:43
still not working. It's rotating on a very strange axis. I tried llRotLookAt() as well but this didn't work either. Any other suggestions?
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-27-2005 15:55
also, once it "looks at" the av the first time, even if the av moves around, the next time the llGetPos() is sent to the script with the eye, it does not move again.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 03:37
bournjour, hola, ni hao, conni chiwa, ellohay, domo arigato mr robato

anyone?
_____________________
Other than that, Mrs. Lincoln, how was the play?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-28-2005 07:10
Post your script so we can see what the issue is, it sounds like you have a couple logic errors.

<singing>Domo Arigato, Mr. Roboto, Domo - Domo</singing>
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 12:39
CODE
float strength = 1.0;
float damping = 1.0;

vector target;

//then later

listen(integer channel, string name, key id, string message)
{
if ( channel == Crot )
{
list listy = llParseString2List(message,[" "],[]);
string namecheck = llList2String(listy,0);
target = llList2Vector(listy,1);
if ( namecheck == title ) //to check if it's the right person it's getting the coordinates from
{
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_ROTATE_Z, TRUE);
llLookAt(target, strength, damping);
}
}
}
_____________________
Other than that, Mrs. Lincoln, how was the play?
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
06-28-2005 12:43
Not only does that snippet not compile, it has no facilities to track the avatar targeted as it moves. You need to set up a sensor repeat so that the script repeatedly gets new information about the targeted avatar, and looks at the appropriate position.
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 12:48
i am continually sending it the llGetPos() of the avatar. It doesn't look at it any time it does it. Also, it doesn't matter which rotate i turn on or off, it always does the same thing and then doesn't move again, even if the avatar moves.

also that is the part of the script in question, not the whole thing. it doesn't even have a state so yes its not going to compile :p
_____________________
Other than that, Mrs. Lincoln, how was the play?
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
06-28-2005 12:59
As Christopher said, you will need to use a sensor, and DetectedPos not GetPos.
_____________________
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 13:00
are you guys sure this is the case? even if the AV is sending the llGetPos for the object to look at. doesn't this give the same information that a sensor would, the location? Oh well I'll give it a try, but I was hoping to reduce lag and avoid a sensorrepeat.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
06-28-2005 13:03
llGetPos()

Returns the object's position in region coordinates, which are relative to the simulator's southwest corner.

llDetectedPos(integer number)

Returns the position of detected object number (returns <0,0,0> if number is not valid sensed object).
_____________________
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 13:46
There are two scripts, one on the avatar, one in the object.

The one in the avatar is using llSay(Crot,"" + (string) llGetPos() + "";);

The one in the object is receiving this vector and being told to look at it using llLookAt()

I will do the sensor, as I said, I was trying to avoid lag causing functions and using a listen on a non zero channel, but whatever.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
06-28-2005 14:15
From my personal experiance a non zero listen has about as much lag as a sensorrepeat with a fast to breakneck speed repeat rate, plus you don't have to spew your GetPos results out for other scripts listening on that particular channel.
From: Douglas Callahan
i am continually sending it the llGetPos() of the avatar.

That has me a bit worried too, you probably don't need to parse that information all that fast, as a medium speed "eye" (repeat of 4-6 seconds) will probably look about the same as one parsing infomation every 1/2 second or so.
A sensor also has the added benifit of being in one object, so you dont have to have the "eye" and wear your attachment as well.
_____________________
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
06-28-2005 14:28
ok ill do that. Before the thing was only sending the information at a specific time, not every second. Thanks for all the help :)
_____________________
Other than that, Mrs. Lincoln, how was the play?