Difference between revisions of "Talk:LlSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
Line 104: Line 104:
<lsl>llSetLinkPrimitiveParams(linkNum, [PRIM_POS_LOCAL, pos + <0.0, 0.0, 0.4> - (llRot2Up(rot) * 0.05), PRIM_ROT_LOCAL, rot]);</lsl>
<lsl>llSetLinkPrimitiveParams(linkNum, [PRIM_POS_LOCAL, pos + <0.0, 0.0, 0.4> - (llRot2Up(rot) * 0.05), PRIM_ROT_LOCAL, rot]);</lsl>
::::This of course using the new <code>PRIM_POS_LOCAL</code> and <code>PRIM_ROT_LOCAL</code> values for simplicity. If one or two others can confirm that the above code works correctly, then I can splice it into the example.<br/>-- '''[[User:Haravikk_Mistral|Haravikk]]''' <sup><small>([[User_talk:Haravikk_Mistral|talk]]|[[Special:Contributions/Haravikk_Mistral|contribs]])</small></sup> 14:16, 26 December 2011 (PST)
::::This of course using the new <code>PRIM_POS_LOCAL</code> and <code>PRIM_ROT_LOCAL</code> values for simplicity. If one or two others can confirm that the above code works correctly, then I can splice it into the example.<br/>-- '''[[User:Haravikk_Mistral|Haravikk]]''' <sup><small>([[User_talk:Haravikk_Mistral|talk]]|[[Special:Contributions/Haravikk_Mistral|contribs]])</small></sup> 14:16, 26 December 2011 (PST)
:::::Be sure to test it with avatars of different shapes, and shoe configurations. I recall that being an issue. {{User|Escort DeFarge}} would know about this best. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 22:05, 26 December 2011 (PST)

Revision as of 22:05, 26 December 2011

Unsitting on wrong side or camera rotation

Hi, i am getting frustrated with this. I create a board and set the sit target with llSitTarget(<0.4, 0.0, 0.0>, ZERO_ROTATION); and an animation which for "standing". So while the person technical sits, she stands in front of the board. But I have a problem with that: If the board stand freely, the person unsits right through it towards the other side. I can put the board with the back facing a large wall. In the case the unsitting is correctly in front of it. But on sit down the camera rotates, so that it is behind the avatar again; on the other side of the wall.

If anyone has an idea how to fix, please tell me (even if it is just an idea where to look for more information). --Maike Short 12:41, 24 February 2008 (PST)

You could position the camera with the Camera functions. -- Strife Onizuka 04:46, 25 February 2008 (PST)

Optimization

<lsl> list GetSitTarget(integer prim, key av) {//WARNING: llGetObjectDetails can introduce an error that goes as far as the 5th decimal place.

   vector tp = llGetAgentSize(av);
   if(tp)
   {
       if(prim == LINK_THIS)//llGetLinkKey doesn't like LINK_THIS
           prim = llGetLinkNumber();
   
       list details = OBJECT_POS + (list)OBJECT_ROT;
       rotation f = llList2Rot(details = (llGetObjectDetails(llGetLinkKey(prim), details) + llGetObjectDetails(av, details)), 1);
   
       return [(llRot2Up(f = (llList2Rot(details, 3) / f)) * tp.z * 0.02638) +
               ((llList2Vector(details, 2) - llList2Vector(details, 0)) / f) - <0.0, 0.0, 0.4>, f];
   }
   return [];

}//Written by Strife Onizuka </lsl>

Using llSetLinkPrimitiveParams for skydiving: why limited to 5m in a linked set?

llSetLinkPrimitiveParams can be used as a handy tool to adjust an avatar's position and rotation. This works perfectly when the object consists of 1 prim, with a range for setting the avatar position away to 500m easily! When there are more prims linked, this offset seems to be limited to 5m (measured with llVecDist). This is an awfull sideeffect!

Put this next script inside a prim and sit on the prim, it will bring you to 1000.0 higher then the prim. Next link this prim to another prim and try again. You will notice you are limited to 5m. My Question: why is this limited? <lsl> // by Randur Source

integer heightcnt = 0; list heights = [0.0, 1.0, 5.0, 6.0, 10.0, 100.0, 300.0, 500.0, 800.0, 1000.0];

default {

   state_entry()
   {
       llSitTarget(ZERO_VECTOR,ZERO_ROTATION); // Clear the current sittarget for a clear test
       llSetRot(ZERO_ROTATION); // set the prim to no rotation, for simple z axis movement
   }
   
   changed(integer change)
   {
       if (change & CHANGED_LINK) // detect linked prims and avatars
       {
           integer primnum = llGetNumberOfPrims(); // the avatar is the last linked prim
           if (primnum <= 1) // stop if there is only 1 prim
               return;
       
           key avatar = llGetLinkKey(primnum);
           if (llGetAgentSize(avatar) == ZERO_VECTOR) // stop if this is not an avatar
               return;
               
           // loop through the list of test heights:
           for (heightcnt = 0; heightcnt < llGetListLength(heights); heightcnt++)
           {
               float height = llList2Float(heights,heightcnt);
               llSetLinkPrimitiveParams(primnum,[PRIM_POSITION,<0.0,0.0,height>]); // set this to the wanted height using a vector z axis
               
               vector avatarpos = llList2Vector(llGetObjectDetails(avatar,[OBJECT_POS]),0); // detect the avatar position within the sim
               float distance = llVecDist(llGetPos(),avatarpos);
               llOwnerSay("Attempt to move " + llKey2Name(llGetLinkKey(primnum)) +
                          " to " + (string)height + "m high resulting to " + (string)distance + "m");
               
               llSleep(1.0);
           }
           llUnSit(avatar);
       }
   }

} </lsl>

Posted by Sylvio Runo : Answer  : The correct limit is 54 meters. You can't move a linked object more than 54 meters away from the axis of the root prim. On SecondLife (other grids like OsGrid, may works diferent) when an agent sit on prim, the agent is attached to it, so the agent is a linked prim of the link set.

More information about link rules, you will find here : http://wiki.secondlife.com/wiki/Linkability_Rules [1]

UpdateSitTarget changes?

I recently worked on a project where I used a version of this function, and it appears that it is a little off. A couple of things I noted: the Z-offset of the sit target is 0.35, not 0.4, and the avatar size doesn't seem to affect this position at all. When I used this function verbatim, I noticed discrepancies between the actual sit target and the set position call. When I changed the script as noted, I got a perfect match. Has the handling of the sit target been changed since this was written? Talarus Luan 22:57, 1 July 2009 (UTC)

Seconded. I wish I'd looked at this discussion before spending an hour on trying to figure out how the code actually behaved. -- Tonya Souther 15:11, 19 August 2009 (UTC)
This is news to me but I haven't been in world in ages :( -- Strife (talk|contribs) 22:56, 20 August 2009 (UTC)
From some quick testing in 1.40, this seems to be how the "true" offset is computed:
1. Start with offset as provided by LSL.
2. Add < 0.0 , 0.0 , 0.4 >
3. Subtract llRot2Up( rot ) * 0.05
--Gregory Maurer 20:00, 28 August 2010 (UTC)
Confirmed. The following appears to work fine:

<lsl>llSetLinkPrimitiveParams(linkNum, [PRIM_POS_LOCAL, pos + <0.0, 0.0, 0.4> - (llRot2Up(rot) * 0.05), PRIM_ROT_LOCAL, rot]);</lsl>

This of course using the new PRIM_POS_LOCAL and PRIM_ROT_LOCAL values for simplicity. If one or two others can confirm that the above code works correctly, then I can splice it into the example.
-- Haravikk (talk|contribs) 14:16, 26 December 2011 (PST)
Be sure to test it with avatars of different shapes, and shoe configurations. I recall that being an issue. Escort DeFarge would know about this best. -- Strife (talk|contribs) 22:05, 26 December 2011 (PST)