Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotating Pets with Avatar

Bubba Gumshoe
Registered User
Join date: 29 Jul 2005
Posts: 4
07-31-2005 06:57
Hi all I am new here I was playing about with a pet script that I found on the forums but having a problem. The script is nice but when I walk about the Pet does not rotate with me does anyone know how the script can be modifed to rotate with avatar to make it look like it is following me ?

CODE
////////////////////////////////////////////////////////////////////////
// Open Shifting Float and Follow Script, by Foolish Frost. //
// From Open Basic Follower/Facing Script, by Logan Bauer. //
///////////////////////////////////////////////////////////////////////
// OFFSET is the position of your pet in relation to it's owner's position.
// For example, in the default setting below, "vector offset =<-1,0,1>;"
// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
// it stay left or right, and 1 means have it stay 1m above it's owner.
// So, if you wanted the script to make it follow directly in front of you,
// and to the left, then you would change it to "vector offset =<1,1,0>;"


// llFrand(float max)

vector offset =<-1.2,0,1>;
vector currentoffset =<0,0,0>;
float xshift =.2; //How far it roams forward and back.
float yshift =1.25; //How wide it roams left to right.
float bob =2; //multiplyer of the BobCycle listed below.
float shifttime =5; //average time it takes to shift to another XY position.
integer timeset=0; //Is the timer running?
float currentxshift =0; //current X shift position
float currentyshift =0; //current Y shift position
float currentyfacing =0; //currentyfacing storage
integer currentbob; //current state of the BobCycle
float bobbing =0; //bob storage
list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];


startup()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z,TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
key id = llGetOwner();
llSensorRemove();
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
}

default
{
state_entry()
{
startup();


}

on_rez(integer start_param)
{
startup();
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);

bobbing = llList2Float(BobCycle, currentbob)*bob;

llSetTimerEvent(llFrand(shifttime));
currentoffset = <currentxshift, currentyshift, bobbing>;
llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3);
if (currentyshift>=0)
{
currentyfacing = currentyshift;
} else {
currentyfacing = currentyshift*-1;
}

llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);

currentbob = currentbob +1;
if (currentbob == 16)
{
currentbob = 0;
}

if(timeset==0)
{
timeset = 1;
llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2);
}


}

timer()
{
timeset = 0;
currentyshift = llFrand(yshift*2)-yshift;
currentxshift = llFrand(xshift*2)-xshift;
}
}


This is the script for anyone who can tell me or help me to get it to rotate so it looks like its following me.

Thanks all :)
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
07-31-2005 07:40
There are many ways to do what you're asking, and you're not being very specific.
Anyways, the llRotLookAt command will solve all your problems.
Bubba Gumshoe
Registered User
Join date: 29 Jul 2005
Posts: 4
07-31-2005 08:27
Thanks figured out what the problem was :)
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
08-01-2005 04:44
you should post your solution for others.
_____________________