Jump to content

Need help with Camera view above a moving object please.... Thanks so much


kiki Chaika
 Share

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

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

Recommended Posts

Greetings! Greetings! I would like to ask if there is a way when someone click on and object, it will allow the user to view as the object's perspective (or better yet, cam just above and behind it); the avatar has the option to "view as the moving object"? please? In other words, when you click on an object, a moving object in this case, a menu pops up which allow the user to view from the perspective of the moving object please? Any help will be great please... I really do not know much about scripting; if you can kindly please post the code on how to do this, it will be of great help. Thank you very much in advance kiki

Link to comment
Share on other sites

thank you Ruth.

 

I actually tied to anaylze that thread you have given before I post this here...  but that script is viewing the obejct from the avatar's pespective.  while I would like to see if the script can be adjusted so that the camera is above the moving object instead.  I have studied and researched over 10 hr on this with no results, that is why I asked.  thanks.

Link to comment
Share on other sites

thank you very much in advance....

 

The object will be a moving object.... and if the cam view is like above and behind it....  "third" person view...

It will be perfect since it will allow the user to control the moving object, while seeing what the object "sees"

 

Thanks so much!!!!!

Link to comment
Share on other sites

Here is what I have put together.

The first one will put your camera 1 meter in front of the object being followed. I didn't like the results of having it following behind, as it made the object look jittery, maybe someone else can fine tune that? I rarely work with cameras, and it's usually a stationary setting when someone sits on an object. I placed it into a HUD object so that it can be clicked on while following the object.

The second script is the test script I put into the object being followed. It communicates using llRegionSayTo when someone clicks it. If the person clicking it is wearing the hud object, the hud object will ask if they would like to follow the object they clicked

integer onoff;//toggle to determine whether or not to show the the dialog when touched. won't show if it is in idle stateinteger comchan = -991119;//this channel is for communication between the object being followed and the hud device, make sure they use the same channelinteger avchan;integer GotCam;//toggle to determine if the script has permissions to control camerainteger handler;key object;//the uuid of the object being followedsetcamera(vector pos, rotation rot)//set the camera params based on the object's position and rotation{    llSetCameraParams([        CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive        CAMERA_FOCUS, pos+(<10.0,0.0,0.0>*rot),//focus 10 meters in front of the object        CAMERA_FOCUS_LOCKED,TRUE,        CAMERA_POSITION, pos+(<1.0,0.0,0.0>*rot),//place the camera 1 meter in front of the object-adjust as desired-<-1.0,0.0,1.0> will be 1 meter behind, and above the object        CAMERA_POSITION_LAG,0.0,        CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)    ]);}getcam(key id){    llRequestPermissions(id,PERMISSION_CONTROL_CAMERA);}avlisten()//this is the listener the dialog will communicate to{    llListenRemove(handler);    avchan = (integer)llFrand(-2000)-2000;    handler = llListen(avchan,"",llGetOwner(),"");}default{    state_entry()    {        llListen(comchan,"","","Here");//listens for the word "Here" from the object being followed. Object should use llRegionSayTo to communicate only to the avatar(and their attachments) who touches it        avlisten();    }        on_rez(integer param)    {        avlisten();    }    listen(integer chan, string name, key id, string message)    {        if(chan == comchan)//        {            object = id;            llDialog(llGetOwner(),            "Would you like to follow " + name +"?",            ["Yes","No"],            avchan);        }        else if(message == "Yes")//if the "Yes" button is pressed on the dialog        {            if(GotCam)//if we already have camera permissions, start following            {                list params = llGetObjectDetails(object,[OBJECT_POS,OBJECT_ROT]);                vector pos = llList2Vector(params,0);                rotation rot = llList2Rot(params,1);                 setcamera(pos,rot);                onoff = TRUE;                llSetTimerEvent(0.0001);            }            else//if we don't already have camera permissons, ask for them            {                getcam(id);            }        }        else if(message == "Stop" || message == "No")//stops/doesn't start following and resets camera to default        {            onoff = FALSE;            llSetTimerEvent(0.0);            llClearCameraParams();            llSetCameraParams([CAMERA_ACTIVE, 0]);            object = "";        }    }        attach(key id)    {        if(llGetAttached())        {            getcam(id);        }    }        run_time_permissions(integer perms)    {        if(perms & PERMISSION_CONTROL_CAMERA)        {            GotCam = TRUE;//permissions granted, toggle On            if(object)//if the object uuid is alread captured before asking for permissions to control camera, let's start following            {                list params = llGetObjectDetails(object,[OBJECT_POS,OBJECT_ROT]);                vector pos = llList2Vector(params,0);                rotation rot = llList2Rot(params,1);                 setcamera(pos,rot);                onoff = TRUE;//following started, toggle On                llSetTimerEvent(0.0001);            }        }        else//if permissons declined for some reason        {            onoff = FALSE;            object = "";            llSetTimerEvent(0.0);            llSetCameraParams([CAMERA_ACTIVE, 0]);        }    }        timer()    {        if(object)//if the object uuid isn't NULL_KEY        {            list params = llGetObjectDetails(object,[OBJECT_POS,OBJECT_ROT]);            vector pos = llList2Vector(params,0);            rotation rot = llList2Rot(params,1);             setcamera(pos,rot);        }        else//probably won't get here, but just in case the timer event sneaks in after telling it to stop(uuid will be cleared first)        {            llSetTimerEvent(0.0);            llSetCameraParams([CAMERA_ACTIVE, 0]);        }    }                 touch_start(integer total_number)    {        if(onoff)        {        llDialog(llGetOwner(), "Click 'Stop' to stop following",["Stop","Cancel"],avchan);        }    }        }
// Shared Data (must be the same in the other script)// --------------------------------------------------integer CommsChannel = -991119;string TargetName = "Helicopter";default{    on_rez(integer StartParam){        llResetScript();    }        touch_start(integer n)    {        llRegionSayTo(llDetectedKey(0),CommsChannel,"Here");    }    state_entry(){    llSetObjectName(TargetName);    llSetLinkPrimitiveParamsFast(LINK_THIS,    [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);    llSetKeyframedMotion(    [<0.0, 0.0, 10.0>, llEuler2Rot(<90, 45, 180> * DEG_TO_RAD), 5,        <0.0, 0.0, -10.0>, llEuler2Rot(<270, 225, 360> * DEG_TO_RAD), 5],    [KFM_MODE, KFM_PING_PONG]);    }}
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2790 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...