LlSitTarget/ja - Second Life Wiki

LlSitTarget/ja

From Second Life Wiki

LlSitTarget/ja
Jump to: navigation, search

関数: llSitTarget( vector offset, rotation rot );

このオブジェクトの座る位置を設定します。

• vector offset sit targetのローカル位置を付加調整。
• rotation rot sit targetのローカル回転を付加調整。

offset<0.0, 0.0, 0.0>の場合、sit targetは取り除かれます。

警告

  • 一度SitTargetを除去すると、llAvatarOnSitTargetNULL_KEYのみを返します。
  • パイメニューからsitオプションを除去する方法はありません。
    • llSetSitTextにスペースの" "を設定した場合、取り除かれた表示になるでしょう。
  • アタッチメント上には設定できません。
  • llSetTargetは既にアバターが座っている位置の更新はしません。
    • UpdateSitTargetはこの問題周りの以下の動きが記述されています。 llSetLinkPrimitiveParamsにそって通されたリンク位置にsit targetの情報が変更するように動きます。

default
{
    state_entry()
    {
        llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION); //The vector's components must not all be set to 0 for effect to take place.
    }
}

部分的な利用

SitTargetを更新

//Sets / Updates the sit target moving the avatar on it if necessary.
UpdateSitTarget(vector pos, rotation rot)
{//Using this while the object is moving may give unpredictable results.
    llSitTarget(pos, rot);//Set the sit target
    key user = llAvatarOnSitTarget();
    if(user)//true if there is a user seated on the sittarget, if so update their position
    {
        vector size = llGetAgentSize(user);
        if(size)//This tests to make sure the user really exists.
        {
            //We need to make the position and rotation local to the current prim
            rotation localrot = ZERO_ROTATION;
            vector localpos = ZERO_VECTOR;
            if(llGetLinkNumber() > 1)//only need the local rot if it's not the root.
            {
                localrot = llGetLocalRot();
                localpos = llGetLocalPos();
            }
            pos.z += 0.4;
            integer linkNum = llGetNumberOfPrims();
            do{
                if(user == llGetLinkKey( linkNum ))//just checking to make sure the index is valid.
                {
                    llSetLinkPrimitiveParams(linkNum,
                                            [PRIM_POSITION, ((pos - (llRot2Up(rot) * size.z * 0.02638)) * localrot) + localpos,
                                             PRIM_ROTATION, rot * localrot / llGetRootRotation()]);
                    jump end;//cheaper but a tad slower then return
                }
            }while( --linkNum );
        }
        else
        {//It is rare that the sit target will bork but it does happen, this can help to fix it.
            llUnSit(user);
        }
    }
    @end;
}//Written by Strife Onizuka, size adjustment provided by Escort DeFarge

SitTargetを取得

list GetSitTarget(integer prim, key av)
{//WARNING: llGetObjectDetails can introduce an error that goes as far as the 5th decimal place!
 //This is highly unlikely to be ever noticed unless compounded over time.
 //Do not use while moving (like in a moving vehicle)!!!
    vector tp = llGetAgentSize(av);
    if(tp)
    {
        if(prim == LINK_THIS)//llGetLinkKey doesn't like LINK_THIS
            prim = llGetLinkNumber();
 
        list details = [OBJECT_POS, OBJECT_ROT];
        rotation f = llList2Rot(details = (llGetObjectDetails(llGetLinkKey(prim), details) + llGetObjectDetails(av, details)), 1);
        rotation r = llList2Rot(details, 3) / f;
 
        return [((llList2Vector(details, 2) - llList2Vector(details, 0)) / f) + (llRot2Up(r) * tp.z * 0.02638) - <0.0, 0.0, 0.4>, r];
    }
    return [];
}//Written by Strife Onizuka

関連項目

イベント

•  changed

関数

•  llSetSitText
•  llAvatarOnSitTarget
•  llUnSit
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。