Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Land Follow Script

Pru Costello
Not My President
Join date: 5 Jun 2005
Posts: 25
09-16-2005 03:32
I'm trying to make an object follow me using llmovetotarget but i want it to stay along the ground or the platform i'm on, i've tried using:

llDetectedPos(0) - (llGetAgentSize(llDetectedKey(0)) / 2)

For the height of the object when it moves to it still seems to hover a little bit off the floor, any ideas on how this could be done?
Julian Fate
80's Pop Star
Join date: 19 Oct 2003
Posts: 1,020
09-16-2005 03:42
If you look closely you might notice you hover a little bit off the floor. It's messy but you could try:

llDetectedPos(0) - (llGetAgentSize(llDetectedKey(0)) / 2) - offset

Where offset is a vector like <0,0,-0.1> or whatever you need.

Personally I would assign the (llGetAgentSize(llDetectedKey(0)) / 2) - offset part to a variable when the object initializes so that you don't have to calculate that over and over again.

Something like:
CODE
// This is untested sorta fake code. Don't try to compile.

// A slight drop to account for that hover you mentioned.
vector adjustment = <0,0,-0.1>;
vector offset;

default {
state_entry() {
vector height = llGetAgentSize(llDetectedKey(0));
// You really only need the avatar height, not width and depth.
offset.z = (height.z / 2) - adjustment;
}

// The movement part.
llDetectedPos(0) - offset;
}
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
09-25-2005 10:24
Hey, look over there. :)

I would also recomment what Jesrad describes here, using the vehicle system to make the pet move.