Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotating spotlight. Help needed!

Moonshine Herbst
none
Join date: 19 Jun 2004
Posts: 483
11-15-2004 13:07
I'm building a spotlight for my stage. But I want it to follow the avatar around on the stage by rotating the root object so that it points to the avatar. I've been searching, reading the Wiki, trying out wild Euler2Rot formulas, etc, etc. In the end, I dont have a clue what I'm doing wrong. I've had the wildest rotations on that spot, but I never got it to point at my AV.

Here's what I have so far. Unfortunately, this makes the spot point right down on the ground. :)

CODE
default
{
state_entry()
{

llSensorRepeat("","",AGENT,30.0,PI,5);

}

sensor(integer n)
{

vector yourpos=llDetectedPos(0); //Avatar's position
vector mypos=llGetPos(); // Spotlight's position


mypos=llVecNorm(mypos);
yourpos=llVecNorm(yourpos);

rotation newrot=llRotBetween(mypos,yourpos);
llSetRot(newrot);


}
}


Please help! :) I'm lost.
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
11-15-2004 13:09
llLookAt(llDetectedPos(0), 2, 2) possibly with the forward axis the tip of the spotlight light.
Satemreh Suavage
Registered User
Join date: 18 Sep 2004
Posts: 10
11-15-2004 13:54
Yeah, all you need is llLookAt() is all you need! :)
Moonshine Herbst
none
Join date: 19 Jun 2004
Posts: 483
11-15-2004 16:50
thanks. I got it working.
Trifen Fairplay
Officially Unofficial
Join date: 19 Jul 2004
Posts: 321
11-15-2004 17:03
yoink
Zennoa Seifert
Registered User
Join date: 28 Oct 2005
Posts: 17
06-13-2006 03:52
How did you get this to work? I tried it, not using a sensor but having the target object broadcast it's position on channel 180. I'm using llLookAt and the position is coming in just fine but my spotlight's rotating around the center of the prim (and the actual light cone is part of it), and sometimes not one of it's axes will actually point at the target (setting coordinate to local to see where it's going). Am I not supposed to be using a prim for the actual light cone?

In fact I'm trying to set up a mobile dance area and I want to be able to control multiple spotlights from a main control center which will tell them where to point.