Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Advanced Pet 'Float and Follow' script for pets. Based off Logan Bauer's work.

Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
04-18-2005 03:40
After looking at the basic pet script for making a following per, I decided to upgrade it for a slightly more organic movement model.

See here for the original script...

While I might sell the bots later, I felt it was a good idea to share the script upgrade publicliy. Only right since based off another's open-source work.

// 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];

vector pos = llGetPos();
key id = llGetOwner();



on_rez(integer start_param)

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

bobbing = llList2Float(BobCycle, currentbob)*bob;

currentoffset = <currentxshift, currentyshift, bobbing>;
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;

timeset = 1;


timeset = 0;
currentyshift = llFrand(yshift*2)-yshift;
currentxshift = llFrand(xshift*2)-xshift;
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion threadt:
04-21-2005 22:31
i've got nothing. ;)
Severe Whiplash
A.K.A Ywoski Khan
Join date: 3 Oct 2004
Posts: 381
06-09-2005 06:17
Another prime example that i shud frikkin well check these forums more than i do, i made a Sith Seeker Droid can just as easily be a Normal seeker droid but none the less a Star Wars Seeker Droid replica, this script shud be a very good start in getting it script :D

A.K.A Ywoski Khan - Founder and Sith Lord of the Shadow Syndicate
Sith Lord of Dark lords of the Sith (lvl 3)

Admiral in the New Imperial Navy
Clone Lieutenant in the Grand Army of the Republic

Kipani Oceanlane
Registered User
Join date: 28 Nov 2007
Posts: 0
Beginner seeking help...
01-15-2008 10:08
Hi I'm new & trying to learn how to do so many things inside SL...

basic question here is... if I make an object, to be like a pet, where do I enter the script? Mind you I'm new & really want to learn this as a HUGE stepping stone in the learning process :o) New to scripting.

Also any suggestions on a site or something to help advise on building a pet? I know for clothing they have many tutorials with maps to guide you etc. Anything like that for making an object like a pet?