Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rotating object around avatar

Bostek Nostram
Registered User
Join date: 4 Oct 2008
Posts: 8
10-04-2008 03:39
Object is rotating around me, but when someone comes beetwen me and object it stops? I used llDetectedName(0) and sensor- so it is rotating around first person that object seen. So wha it stops when someone is meetwen us?
Bostek Nostram
Registered User
Join date: 4 Oct 2008
Posts: 8
10-04-2008 04:07
This is code:

string avatar;
string avatar_ena;
integer status=1;
integer stevec=0;
key uuid;
key owner;
vector rotationCenter;

default
{
state_entry()
{
uuid= llGetKey();
owner = llGetOwner();


llListen( 995, "", NULL_KEY, "";);

llSetStatus(STATUS_PHYSICS, TRUE);
llSensorRepeat("", llDetectedName(0), AGENT, 50.0, PI, 0.4); //

}







sensor(integer skupaj)
{

llSay(211,"phobia";);
stevec++;
if(stevec==1){

avatar_ena=llDetectedName(0);
avatar=llDetectedName(0);


}
else avatar=llDetectedName(0);

// llSay(0,llGetOwner());

if(avatar==avatar_ena)
{

vector pozicija_avatarja=llDetectedPos(0);
vector pozicija_objekta=llGetPos();
float x1=pozicija_avatarja.x;
float x2=pozicija_objekta.x;
float y1=pozicija_avatarja.y;
float y2=pozicija_objekta.y;

float razdalja2= (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
float razdalja = llSqrt(razdalja2);
// llSay(0,(string)razdalja+(string)llDetectedPos(0));

if(razdalja>10)
{

llMoveToTarget(llDetectedPos(0),0.1);

}
else
{
// llSay(0,(string)llGetPos());
vector pos = llDetectedPos(0); // prebere prvi rezultat skeniranja (indeks 0) in sicer pozicijo
vector startPoint = llGetPos();
if(pos.z<23){ pos.z=23; rotationCenter = pos; }
else rotationCenter = pos;



rotation Z_15 = llEuler2Rot( < 0, 0, 20 * DEG_TO_RAD > );

integer r;
// for( r = 1; r < 100; r++ )
//{
vector currentPosition = llGetPos();

vector currentOffset = currentPosition - rotationCenter;
//rotation center je pozicija avatarja
vector rotatedOffset = currentOffset * Z_15;

vector newPosition = rotationCenter + rotatedOffset;
newPosition.z -= rotatedOffset.z;

//llSay(0,(string)pos +" pos pajka: " + (string)newPosition+" offset: "+ (string)rotatedOffset);
llMoveToTarget(newPosition,0.3);
}
}
}

listen(integer channel, string name, key id, string choice )
{

string primerjava = "You are cured "+ avatar;

if(primerjava == choice)
{
llSay(0,choice+ " You had phobia.";);
llSay(995,"bolezen";);
status=0;

llSay(994,"izbris";);
llDie();
}
else llSay(998,"You are not infected.";);

}
}
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-04-2008 05:24
You've got this line in the "state_entry" event:

llSensorRepeat("", llDetectedName(0), AGENT, 50.0, PI, 0.4);


The "llDetected*" functions won't actually work in there. If you want it to follow you only, then put "owner" in there instead (since you had already stored the owner's key in there anyway).