Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attachment that looks where avatar is looking

Psyra Extraordinaire
Corra Nacunda Chieftain
Join date: 24 Jul 2004
Posts: 1,533
06-18-2006 15:11
I've seen this done. :)

Basically, I want the head of a little attachment critter I've made to turn its head to follow what its 'owner' is looking at. The head is seperate from the body and is its own attachment, so all it needs to do is rotate pretty much, the body is stationary.

Anyone? Bueller? Bueller? Please? :D
_____________________
E-Mail Psyra at psyralbakor_at_yahoo_dot_com, Visit my Webpage at www.psyra.ca :)

Visit me in-world at the Avaria sims, in Grendel's Children! ^^
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
06-18-2006 16:50
it would use both llLookAt & llGetCameraPos (llGetCameraPos needs to get permission, PERMISSION_TRACK_CAMERA)

Im not sure how llLootAt will work with attachment though.
_____________________
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
06-18-2006 17:24
In mouselook, you can get the look direction as the "rotation" of the avatar, and in normal mode or mouselook you can get the camera location and direction by using the camera track calls.

However, if you mean the head movements that the avatar performs as the mouse is moved around, looking towards the mouse pointer, then I'm afraid I don't think you can read those from script :(
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
06-18-2006 17:37
I'm afraid Yumi is right, there isn't any way to know which way the head is facing using LSL, this is because (from my understanding) the avatar is implemented client side, meaning that the server only "sees" the avatar as a box.

Perhaps you could find some way to use a head attachment point but I don't know how you would line up the head/shoulder of your attachment critter. Might be possible to have the whole critter as a head attachment but it may end up floating off your shoulder when you look too far to one side or buried in your torso with some obscure pose.

In the end I'd go for llGetCameraPos together with llGetCameraRot and aim your critter's head/eyes at an assumed focal distance. i.e. perhaps take a 15m (guess-timate) focus point ahead of the camera position. Also code in a limit to the rotation (unless your critter is an owl) and have the head rotate to something like 120deg max off centre.

</spouting rubbish>

Hope some small part of my ramblings help.
nN
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
06-18-2006 18:15
From: Gattz Gilman
it would use both llLookAt & llGetCameraPos (llGetCameraPos needs to get permission, PERMISSION_TRACK_CAMERA)

Im not sure how llLootAt will work with attachment though.



Also consider taking a look at llDetectedRot and sensors.
==Chris
Psyra Extraordinaire
Corra Nacunda Chieftain
Join date: 24 Jul 2004
Posts: 1,533
06-18-2006 18:35
I know it has been done in the past, as I have avatars from two people that do indeed have heads that do that. unfortunately, neither of them have been on for a while.... so I can only wait.... :>
_____________________
E-Mail Psyra at psyralbakor_at_yahoo_dot_com, Visit my Webpage at www.psyra.ca :)

Visit me in-world at the Avaria sims, in Grendel's Children! ^^
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
06-18-2006 19:09
From: nand Nerd
I'm afraid Yumi is right, there isn't any way to know which way the head is facing using LSL, this is because (from my understanding) the avatar is implemented client side, meaning that the server only "sees" the avatar as a box.


You're right that the avatar is seen as a box, but the turning head can be seen on other people's screens, so presumably it is being sent to the server somewhere (?)
Candide LeMay
Registered User
Join date: 30 Dec 2004
Posts: 538
06-18-2006 23:14
Interesting idea. I've done prim eyes that follow avatars around you, which is quite similar to this. I'll give it a try
_____________________
"If Mel Gibson and other cyberspace writers are right, one day the entire internet will be like Second Life." -- geldonyetich
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
06-19-2006 01:47
One way I can think of....

if you have an additional attachment, to a head point, which finds its rotation (which would track the head), and sends that to the shoulder attachment, which is your shoulder-sitter's head, you may be able to use that to set the alignment to match the avie's head alignment.
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
06-19-2006 07:03
From: Bitzer Balderdash
One way I can think of....

if you have an additional attachment, to a head point, which finds its rotation (which would track the head)


Sadly this also can't be done :(

Attachments return their position and rotation relative to their attachment point. When the avatar rotates their head, the attachment point rotates, but the attachment doesn't rotate relative to the attachment point, so the rotation returned is still the same. And there is no way to get the rotation of the attachment point :( probably because it is calculated only on the client.
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
06-19-2006 20:41
after some thinking, the closest you would be able to get is just using llGetCameraRot and using the returned rotation to use on the head. for normal camera use it will work. but if your panning around then the head of the critter wont match the avatar's. also setting a limit to how far the head can rotate would be good, unless the critter is supposed to spin its head 360 degrees lol

good luck
_____________________