Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Follow other avatars

Samantha Widdershins
Registered User
Join date: 12 Feb 2007
Posts: 5
05-05-2007 09:57
I'm brand new at scripting, although I think I'm catching on fast. Anyway, I've been playing with this script for hours, but I can't manage to make it work. So, does anyone know how to make the Open Shifting Float and Follow Script by Foolish Frost follow other avatars? I don't want the object to push them or cage them, just to bob around and follow them. It's for a magic spell, but I honestly am very lost trying to do this.

Any help would be greatly appreciated!
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
05-05-2007 10:43
you're looking at using llSensorRepeat with a reasonable polling rate (about 3 seconds is decent for non-griefing followers), and then using llMoveToTarget to move your object there by feeding it the sensor's results with the llDetectedKey() call.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Samantha Widdershins
Registered User
Join date: 12 Feb 2007
Posts: 5
05-05-2007 11:38
I'm still lost. :(
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
05-05-2007 12:43
What Senuka said is correct...let me see if I might be able to help in a way that gets you at least slightly un-lost. It also helps us if you post code that you're trying to complete so that we can help you iron out any errors you have in it. Please post them within PHP tags though--helps us read it easily :)

Anyway...

Your object will want to use an llSensorRepeat() function on about 3 second intervals to detect the position of the avatar it is trying to follow...

...in the Sensor() event, you'll grab the sensor info...getting the detected location of the avatar you're looking for (identified by llDetectedKey()) and then using an llMoveToTarget() to get your follower object there.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Samantha Widdershins
Registered User
Join date: 12 Feb 2007
Posts: 5
05-05-2007 13:04
Well I've screwed up the code so much I'm just repasting the original.

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;
}
}


I want that to follow who I say by giving a follow (name) command on a channel of my choice. :-\
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-05-2007 15:43
From: Samantha Widdershins
I want that to follow who I say by giving a follow (name) command on a channel of my choice. :-\


You will need to make it such that it listens to the owner and then when they specify the name of an avatar starts a sensor and then moves to the specified target. Partial name matching isnt difficult. You will probably need it to follow the owner so it stays in chat range when its not following someone.