Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Behavior or llMoveToTarget

Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
08-11-2006 13:19
I am using the script below to move a prim that is a sheet of glass up and down in front of a door opening. I manually move the glass where I want so the bottom edge is sitting on the floor and the inside surface of the glass is against the outside surface of the door frame. I then say "align".

Then I say "up" and the glass glides upward a distance equal to its height (3.8 m). So far so good. Then I say "down" and the glass glides down. However, when it does this, it stops short off the floor exactly 0.366 m and, inexplicably, moves away from the door frame (Y axis) exactly 0.99 m.

What is the deal with this? Everthing in the script seems pretty straightforward - certainly nothing that indicates these odd distances. Does it have something to do with physics? Like is it bouncing off the floor or something?


CODE

state_entry()
{
owner=llGetOwner();
llListen(0,"",owner,"");
llListen(34,"","","down");
llListen(34,"","","up");
llSetStatus(STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z,FALSE);
}

listen(integer a, string n, key id, string m)
{
if(m=="align")
{
pos=llGetPos();
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(pos,.2);
}

if(m=="down")
{
end=pos;
llMoveToTarget(end,.2);
}

if(m=="up")
{
end=pos+<0,0,3.8>;
llMoveToTarget(end,.2);
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-11-2006 14:11
Umm...the object is physical. It could very well be that collisions are causing problems. Do you really need it to be physical? Is it phantom also (wierd if so, since I presume you are trying to implement some kind of door)? I would set it non-physical and use 'llSetPos()' instead.
Grazel Cosmo
Registered User
Join date: 12 Mar 2005
Posts: 28
08-11-2006 14:37
Is there a reason you're setting this physical just to move it? If its physical it will collide with other objects (physical or not) so will adjust itself and therefore not move quite as you are expecting. If you just want a door to slide up and down (or a window) then leave it non-physical and just use llSetPos on it. Quick and dirty just tell it to
CODE
llSetpos(llGetPos() + <0,0,3.8>);
to open it and if you set a variable to store the 'home positoin' (homePos is what I usually use) then to close it you can just tell it to
CODE
llSetPos(homePos)


You may want to use a bit fancier detection to provide support for the object being moved, rotated, or resized but isn't neccessary for something quick that will work as long as its not altered.
Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
08-11-2006 15:31
Awesome, thanks Hewee and Grazel. I'm new at this and, frankly, don't really have a handle on the implications of the whole physical non-physical thing. I also didn't know that llSetPos existed, lol.

The down and dirty example is perfect.

As far as the script explicitly setting to physical, that was there when someone gave it to me. It was really designed for an elevator.

Thanks again!