05-12-2007 14:22
I've been trying to get a camera to move to a fixed location for some time now.
I can't seem to get it to work.

I've read many entries & lsl wiki pages, but, for some reason, my script just won't work for me.

When I sit on a given object, I'd like the camera to go to a preset position
(In the future, assuming I can get this to work, I'll likely present a menu, but for now, 1 position will do.

Here is my script:
CODE

key kAvatar;

MoveCamera()
{
vector vPos = llGetPos();
llOwnerSay("Moving camera...");
llSetCameraParams([CAMERA_ACTIVE, TRUE,
CAMERA_FOCUS, vPos,
CAMERA_FOCUS_LAG, 0.0,
CAMERA_FOCUS_LOCKED, TRUE,
CAMERA_FOCUS_OFFSET, <0, 0, -10>,
CAMERA_PITCH, -80.0,
CAMERA_POSITION_LOCKED, TRUE]);
}

default
{
state_entry()
{
kAvatar = llGetOwner();
llSitTarget(<0.25, 0.0, 0.80>, ZERO_ROTATION);
}

on_rez(integer nNum)
{
llResetScript(); // reset the script
}

changed(integer nWhat)
{
key kAvatar;
if (nWhat & CHANGED_LINK) {
kAvatar = llAvatarOnSitTarget(); // who is sitting ?
if (kAvatar != NULL_KEY) {
llOwnerSay(" kAvatar = " + (string) kAvatar);
llRequestPermissions(kAvatar, PERMISSION_CONTROL_CAMERA);
}
else {
llOwnerSay("No one sitting; reset camera");
integer nPerm = llGetPermissions();
if (nPerm & PERMISSION_CONTROL_CAMERA) {
llClearCameraParams( );
}
}
}
}

run_time_permissions(integer nPerm)
{
if (nPerm & PERMISSION_CONTROL_CAMERA) {
MoveCamera();
}
}

}


(I'm just trying to move the camera up and see change the angle.
Ideally, I'd like to move it to a give pos & rot that I obtained with
llGetCameraPos & llGetCameraRot, but I'll cross that bridge once I get this to work)

Can the camera doesn't move, I've tries changing almost everything.
I can still move the camera manually -- isn't that what the focus & position locks are supposed to prevent?

In any case, any help will be very appreciated.

Thanks in advance,
Xaq