OsNpcSetRot

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(New page: {{osslfunc |function_syntax=osNpcSetRot(key npc, rotation rot) |csharp_syntax= |description=Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will ...)
 
m (Change See Also)
 
(7 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
|csharp_syntax=
 
|csharp_syntax=
 
|description=Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner.
 
|description=Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner.
|threat_level=
+
|threat_level=High
|ossl_example=
+
|permissions=${OSSL|osslNPC}
|additional_info=
+
|delay=0
 +
|ossl_example=<source lang="lsl">
 +
//
 +
// osNpcSetRot Script Exemple
 +
// Author: djphil
 +
//
 +
 +
key npc;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage.");
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        key toucher = llDetectedKey(0);
 +
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
 +
        osAgentSaveAppearance(toucher, "appearance");
 +
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
 +
        state hasNPC;
 +
    }
 +
}
 +
 +
state hasNPC
 +
{
 +
    state_entry()
 +
    {
 +
        llSetTimerEvent(5.0);
 +
    }
 +
 +
    timer()
 +
    {
 +
        llSetTimerEvent(0.0);
 +
        osNpcSay(npc, "Hello world!");
 +
        osNpcSetRot(npc, <0.000000, 0.000000, 1.000000, 0.000000>);
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        osNpcSay(npc, "Goodbye!");
 +
        llSetTimerEvent(0.0);
 +
        osNpcRemove(npc);
 +
        npc = NULL_KEY;
 +
        state default;
 +
    }
 +
}
 +
</source>
 +
'''Or with llEuler2Rot'''
 +
<source lang="lsl">
 +
//
 +
// osNpcSetRot Script Exemple
 +
// Author: djphil
 +
//
 +
 +
key npc;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage.");
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        key toucher = llDetectedKey(0);
 +
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
 +
        osAgentSaveAppearance(toucher, "appearance");
 +
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
 +
        state hasNPC;
 +
    }
 +
}
 +
 +
state hasNPC
 +
{
 +
    state_entry()
 +
    {
 +
        llSetTimerEvent(5.0);
 +
    }
 +
 +
    timer()
 +
    {
 +
        llSetTimerEvent(0.0);
 +
        osNpcSay(npc, "Hello world!");
 +
        osNpcSetRot(npc, llEuler2Rot(<0.0, 0.0, PI>));
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        osNpcSay(npc, "Goodbye!");
 +
        llSetTimerEvent(0.0);
 +
        osNpcRemove(npc);
 +
        npc = NULL_KEY;
 +
        state default;
 +
    }
 +
}
 +
</source>
 +
|additional_info=This function was added in 0.7.2-post-fixes
 
}}
 
}}
 +
== See Also ==
 +
* [[osNpcGetPos]]
 +
* [[osNpcGetRot]]
 +
* [[osNpcSetRot]]
 +
* [[osNpcMoveTo]]
 +
* [[osNpcMoveToTarget]]
 +
* [[osNpcStopMoveToTarget]]

Latest revision as of 18:54, 5 December 2020

osNpcSetRot(key npc, rotation rot)
Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner.
Threat Level High
Permissions ${OSSL|osslNPC}
Extra Delay 0 seconds
Example(s)
//
// osNpcSetRot Script Exemple
// Author: djphil
//
 
key npc;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage.");
    }
 
    touch_start(integer number)
    {
        key toucher = llDetectedKey(0);
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
        osAgentSaveAppearance(toucher, "appearance");
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        llSetTimerEvent(5.0);
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        osNpcSay(npc, "Hello world!");
        osNpcSetRot(npc, <0.000000, 0.000000, 1.000000, 0.000000>);
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Goodbye!");
        llSetTimerEvent(0.0);
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}

Or with llEuler2Rot

//
// osNpcSetRot Script Exemple
// Author: djphil
//
 
key npc;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage.");
    }
 
    touch_start(integer number)
    {
        key toucher = llDetectedKey(0);
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
        osAgentSaveAppearance(toucher, "appearance");
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        llSetTimerEvent(5.0);
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        osNpcSay(npc, "Hello world!");
        osNpcSetRot(npc, llEuler2Rot(<0.0, 0.0, PI>));
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Goodbye!");
        llSetTimerEvent(0.0);
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}
Notes
This function was added in 0.7.2-post-fixes


[edit] See Also

Personal tools
General
About This Wiki