Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Bfl

Shadow Keegan
Registered User
Join date: 3 Aug 2004
Posts: 38
09-28-2005 17:30
is there any way i can make 2 objects and have one follow the other like a laser and fire out of a deck gun here is a example:
O= object 1 , = = object 2
O========Turret
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
09-28-2005 18:26
Try looking the function llLookAt, and couple it with a repeating sensor. I believe that will do what you want.
Shadow Keegan
Registered User
Join date: 3 Aug 2004
Posts: 38
09-29-2005 13:03
i cant seem to get it to work from the turret this is the script i am useing when i go into mouselook it spins around out of control
key toucher;
string toucherS;
float SPEED = 20.0;
integer LIFETIME = 7;
float DELAY = 0.2;
vector vel;
vector pos;
rotation rot;
integer in_use;
integer have_permissions = FALSE;
integer armed = TRUE;
fire()
{

rot = llGetRot();
vel = llRot2Fwd(rot);
pos = llGetPos();
pos = pos + vel;
pos.z += 0.0;
vel = vel * SPEED;
llTriggerSound("shoot", 1.0);
llRezObject("bullet", pos, vel, rot, 1);
}
default
{
state_entry()
{
in_use = FALSE;
}
touch_start(integer total_number)
{
if(in_use == FALSE)
{
toucher = llDetectedKey(0);
llRequestPermissions(toucher, PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION);
llSetText("Requesting Permissions", <1,1,1>, 1);
}
if(in_use == TRUE)
{
if(llDetectedKey(0) == toucher)
{
llReleaseControls();
llSensorRemove();
llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>;);
llSetText("", <1,1,1>, 1);
in_use = FALSE;
}
}
}
sensor(integer sense)
{
rotation k = llDetectedRot(0);
llRotLookAt(k, .1, .1);
}
no_sensor()
{
llReleaseControls();
llSensorRemove();
llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>;);
llSetText("", <1,1,1>, 1);
in_use = FALSE;
}
run_time_permissions(integer perm)
{
if(perm)
{
llSetText("", <1,1,1>, 1);
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llSensorRepeat("", toucher, AGENT, 5, TWO_PI, .1);
llSetText("Current User: "+llKey2Name(toucher), <1,1,1>, 1);
in_use = TRUE;
}
else
{
in_use = FALSE;
llSetText("", <1,3,1>, 1);
}
}
control(key name, integer levels, integer edges)
{
if ((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
{
fire();
}
}

}
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
09-29-2005 15:21
Please use the PHP tags. I have a post on that in this forum, I'd appreciate it if you read it.

That script works perfectly for me on a plywood cube... I don't see what the problem is. Try playing aorund with the damping and strenth values on llLookAt.
Shadow Keegan
Registered User
Join date: 3 Aug 2004
Posts: 38
09-30-2005 07:53
the way i am trying to work the turret is it will be on a big battle ship the "gunner" or the person working the gun will take a seat on a chair in the deck gun and when the gunner gose into mouse look they will be able to move the mouse and that will turn the turret and when they click it shoots. simple right? or thats what i though i modded the deck gun model i had to have a gunner chair made it the key prim then but the scripts in the chair then took a seat went into mouse then then the gun spun out of control and you saw the script i was useing if you cant help here contact me in game and i will show you