Jump to content

How can i get the avatar position or rot?


Wang Novelli
 Share

You are about to reply to a thread that has been inactive for 2196 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

If your object has a scripted sit target, then you obviously know exactly where the avatar sat and what the rotation is.  Otherwise, you can use

llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL])

That should work, since the sitting avatar will always be the last link in your object's link set.

Link to comment
Share on other sites

It's A little bit of a problem

vector LastPos;
rotation LastRot;

 

vector NowPos;
rotation NowRot;

 

LastPos = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCA]);

LastRot = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_ROT_LOCA]);

 

I want to know now before coordinates and the coordinates of the poor

 

 

 

X=NowPos-LastPos?

Y=NowRot-LastRot?

 

Link to comment
Share on other sites

Oh, I see.  And because your object does not have a sit target, there's no guarantee that your av will sit in the same relative spot next time.  I understand now.  

OK, so create a dummy sit target (  llSitTarget(<0.0,0.0,0.0>,ZERO_ROTATION)  ).  Then, when the avatar sits down, save its local position and rotation and reassign those to the dummy sit target.  Then, if the avatar stands up and sits back down again, he'll be sitting on the new sit target that you created.  You might want to have some way to replace that new sit target with the dummy again, maybe after a certain time, or if the avatar leaves the area....

 

Link to comment
Share on other sites

Hi~Rolig, 

when the avatar sits down, save its local position and rotation and reassign those to the dummy sit target.  

you mean is save the object position  ? or avatar position ?

iknow how to save the object position and rotation, but i don't know how to save the avatar position and rotation. 

Link to comment
Share on other sites

As I said earlier, as soon as the avatar sits down, the avatar is the last link in the object's linkset. So the avatar's local position and rotation are easy:

list temp = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);vector LPos = llList2Vector(temp,0);rotation LRot = llList2Rot(temp,1);llSitTarget(LPos, LRot);

 

 

Link to comment
Share on other sites

OK, here's a bare bone script that does what I have been talking about.

vector gAvPos = ZERO_VECTOR;rotation gAvRot = ZERO_ROTATION;vector gHeightOffset = <0.0,0.0,-0.3>;default{    state_entry()    {        llSitTarget(gAvPos,gAvRot);    }    changed (integer change)    {        if(change & CHANGED_LINK)        {            if (llGetObjectPrimCount(llGetKey()) != llGetNumberOfPrims())  //Avatar has sat down            {                llSetTimerEvent(0.0); // If avatar has sat down a second time                if (gAvPos == ZERO_VECTOR)                {                    list temp = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);                    gAvPos = llList2Vector(temp,0) + gHeightOffset;                    gAvRot = llList2Rot(temp,1);                    llSitTarget(gAvPos, gAvRot);                    llOwnerSay("Sit target saved.");                }            }            else    //Avatar has stood up            {                llSetTimerEvent(30.0);                llOwnerSay("Sit target will be removed in 30 seconds.");            }        }                    }        timer()    {        llSetTimerEvent(0.0);        gAvPos = ZERO_VECTOR;        gAvRot = ZERO_ROTATION;        llSitTarget(gAvPos, gAvRot);        llOwnerSay("Sit target erased.");    }}

 The avatar sits down and the script recognizes that the object that the avatar is sitting on has a new link, so it determines the local position and rotation of the new link -- that is, the avatar -- and changes the sit target.  That won't affect the seated avatar, but it will affect the next avatar who sits down.  I have had the script start a 30 second timer as soon as an avatar stands up, as an artificial way to reset the sit target to its ZERO position and rotation.

The only minor factor that I forgot to to include in my comments earler in the extra vector gHeightOffset.  You'll have to determine that offset experimentally.  It's necessary because the avatar's local position is NOT the spot that she/s sitting on; it is the geometric center of the avatar's body, which is a little higher.  (You do not "sit" where your stomach is. You sit on your butt, which is about 0.3m lower.)

 

Link to comment
Share on other sites

<0.30000, 0.00000, 0.35010><0.00000, 0.00000, 0.00000, 1.00000>

<0.30000, 0.00000, 0.35010><0.00000, 0.00000, 0.00000, 1.00000>

 

avarar sit on the  object , save the avatar position and rotation

after chang the object position and rotation, i want to get the avatar's position and rotation

Link to comment
Share on other sites

<0.30000, 0.00000, 0.35010><0.00000, 0.00000, 0.00000, 1.00000> <0.30000, 0.00000, 0.35010><0.00000, 0.00000, 0.00000, 1.00000> avarar sit on the object , save the avatar position and rotation after chang the object position and rotation, i want to get the avatar's position and rotation

Link to comment
Share on other sites

vector YuanShiPos;rotation YuanShiRot;vector NewPos;rotation NewRot;list temp;list temp2;default{changed (integer change)    {         if (change & CHANGED_LINK)        {             key av = llAvatarOnSitTarget();            if (av != NULL_KEY)            {                              temp = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);                    YuanShiPos = llList2Vector(temp,0);                    YuanShiRot = llList2Rot(temp,1);                    llOwnerSay((string)YuanShiPos+(string)YuanShiRot);        }     }               } touch_start(integer total_number)//When I after rotation and position    {  temp2 = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);                    NewPos = llList2Vector(temp2,0);                    NewRot = llList2Rot(temp2,1);                    llOwnerSay((string)NewPos+(string)NewRot);}}

 but I get the same result

Link to comment
Share on other sites

  • 3 years later...

Hello all. I see that this post is old, but I need also to know the position of my avatar sit on a object. I tried to follow the instructions but I don't know scripting and then I have script errors. Someone, please, can help me with a complete script? If my request is unfair, I ask sorry. Thank you.

Edited by Midori Meiyo
wrong word
Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

We don't usually post complete scripts in this forum.  As it happens, though, there is already a complete script, posted above on August 25, 2014.

Hello Rolig, thank you for your help, but I don't see any complete script on August 25, and the others codes give me syntax errors (It is certainly my fault). Nothing for me is frustrating like scripting in SL :D. Still thanks and sorry, I try to search on Marketplace. Bye ^^    

Link to comment
Share on other sites

It's all there.  It's just that the formatting on posted scripts was all messed up when they redid the forums in 2017.  Here's a clean copy...

vector gAvPos = ZERO_VECTOR;
rotation gAvRot = ZERO_ROTATION;
vector gHeightOffset = <0.0,0.0,-0.3>;

default
{
    state_entry()    
    {        
        llSitTarget(gAvPos,gAvRot);
    }    
    
    changed (integer change)    
    {        
        if(change & CHANGED_LINK)        
        {            
            if (llGetObjectPrimCount(llGetKey()) != llGetNumberOfPrims())  //Avatar has sat down            
            {                
                llSetTimerEvent(0.0); // If avatar has sat down a second time                
                if (gAvPos == ZERO_VECTOR)                
                {                    
                    list temp = llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);                    
                    gAvPos = llList2Vector(temp,0) + gHeightOffset;                    
                    gAvRot = llList2Rot(temp,1);                    
                    llSitTarget(gAvPos, gAvRot);                    
                    llOwnerSay("Sit target saved.");                
                }
            }            
            else    //Avatar has stood up            
            {                
                llSetTimerEvent(30.0);                
                llOwnerSay("Sit target will be removed in 30 seconds.");            
            }        
        }
    }
                   
    timer()    
    {        
        llSetTimerEvent(0.0);        
        gAvPos = ZERO_VECTOR;        
        gAvRot = ZERO_ROTATION;        
        llSitTarget(gAvPos, gAvRot);        
        llOwnerSay("Sit target erased.");    
    }
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2196 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...