Difference between revisions of "LlGetCameraPos"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 1210800 by Jenna Huntsman (talk) - Caveat behaviour is variable between viewers, more research required.)
Tag: Undo
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function/permission|PERMISSION_TRACK_CAMERA}}{{LSL_Function
|func=llGetCameraPos
|sort=GetCameraPos
|func_id=303
|func_id=303
|func_sleep=0.0
|func_sleep=0.0
|func_energy=10.0
|func_energy=10.0
|func=llGetCameraPos
|return_type=vector
|return_type=vector
|func_desc
|func_desc
|return_text=that is the current camera position for agent task has permissions for.
|return_text=that is the current camera position for the agent the task has permissions for.
|spec
|spec
|caveats=*Seems to act weird when the camera gets too far from the agent.
|caveats=*Seems to act weird when the camera gets too far from the agent.
|examples
|examples=
<source lang="lsl2">//Camera Follower Script
//llGetCameraPos & llGetCameraRot Example
//By Nika Rugani
 
integer perm_track = 0x400;
float second_check = 0.1;
 
vector object_offset = <2,0,0>; //Offset of the cameras position where the object will set itself
 
integer die_channel = 0;
string die_command = "/die";
 
quickPosRot(vector pos, rotation rot)
{//This way you don't have the 0.2 second sleeps from llSetPos and llSetRot
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, pos, PRIM_ROTATION, rot]);
}
 
default
{
    on_rez(integer a)
    {
        llResetScript();
    }
    state_entry()
    {
        llRequestPermissions(llGetOwner(), perm_track);
    }
    run_time_permissions(integer permission)
    {
        if(permission == perm_track)
        {
            llSetTimerEvent(second_check);
            llListen(die_channel, "", llGetOwner(), "");
        }
        else
        {
            //llResetScript(); //Remove comment to loop the process of requesting permissions if user deny's permission
            //llDie(); //Remove comment to kill the object if user deny's it
        }
    }
    listen(integer channel, string name, key id, string str)
    {
        str = llToLower(str);
        if(str == die_command)
        {
            llDie();
        }
    }
    timer()
    {
        vector c_pos = llGetCameraPos(); //Get Users Camera Position
        rotation c_rot = llGetCameraRot(); //Get Users Camera Rotation
        c_pos = (c_pos+object_offset*c_rot); //Apply the offset to the position
        quickPosRot(c_pos, c_rot); //EXECUTE ORDER!
    }
}</source>
|helpers
|helpers
|related
|also_functions=
|also
{{LSL DefineRow||{{LSLG|llGetCameraRot}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraParams}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraAtOffset}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraEyeOffset}}|}}
|notes
|notes
|sort=GetCameraPos
|cat1=Camera
|permission=PERMISSION_TRACK_CAMERA
|cat2
|cat3
|cat4
}}
}}
[[Category:LSL_Stub]]

Latest revision as of 10:42, 5 June 2022

Summary

Function: vector llGetCameraPos( );
0.0 Forced Delay
10.0 Energy

Returns a vector that is the current camera position for the agent the task has permissions for.

To run this function the script must request the PERMISSION_TRACK_CAMERA permission with llRequestPermissions.

Caveats

Permissions
  • Seems to act weird when the camera gets too far from the agent.

Examples

//Camera Follower Script
//llGetCameraPos & llGetCameraRot Example
//By Nika Rugani

integer perm_track = 0x400;
float second_check = 0.1;

vector object_offset = <2,0,0>; //Offset of the cameras position where the object will set itself

integer die_channel = 0;
string die_command = "/die";

quickPosRot(vector pos, rotation rot)
{//This way you don't have the 0.2 second sleeps from llSetPos and llSetRot
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, pos, PRIM_ROTATION, rot]);
}

default
{
    on_rez(integer a)
    {
        llResetScript();
    }
    state_entry()
    {
        llRequestPermissions(llGetOwner(), perm_track);
    }
    run_time_permissions(integer permission)
    {
        if(permission == perm_track)
        {
            llSetTimerEvent(second_check);
            llListen(die_channel, "", llGetOwner(), "");
        }
        else
        {
            //llResetScript(); //Remove comment to loop the process of requesting permissions if user deny's permission
            //llDie(); //Remove comment to kill the object if user deny's it
        }
    }
    listen(integer channel, string name, key id, string str)
    {
        str = llToLower(str);
        if(str == die_command)
        {
            llDie();
        }
    }
    timer()
    {
        vector c_pos = llGetCameraPos(); //Get Users Camera Position
        rotation c_rot = llGetCameraRot(); //Get Users Camera Rotation
        c_pos = (c_pos+object_offset*c_rot); //Apply the offset to the position
        quickPosRot(c_pos, c_rot); //EXECUTE ORDER!
    }
}

See Also

Events

•  run_time_permissions Permission receiving event

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llGetCameraRot
•  llSetCameraParams
•  llSetCameraAtOffset
•  llSetCameraEyeOffset

Articles

•  Script permissions

Deep Notes

Signature

function vector llGetCameraPos();