Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

View change on controls

Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
07-13-2009 23:08
Hi all...

an avatar, sitting on an object that takes controls, and the keyboard maps well. The object also sets the camera position via a different script.

Now if one moves the camera (alt+mouse), that is fine... but the use of the movement keys causes the camera to snap back, which in this case is not a good behavior.

What can be done?

Pls help! :)

Thanks!

-rs-
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-14-2009 16:40
A few questions:

The script that "sets the camera position"--does it do that with llSetCameraParams(), or is it just setting properties of the prim with llSetCameraAtOffset() and -EyeOffset() ?

Is the last argument passed to llTakeControls() TRUE or FALSE?

The position to which the camera snaps back when a movement key is pressed, is that the position the script sets (and you wanted the keys to do something different with the cam), or is it that the movement keys cause the cam to revert to normal behavior (and you wanted them to have no effect on the cam)?
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
07-15-2009 00:00
From: Qie Niangao
A few questions:

The script that "sets the camera position"--does it do that with llSetCameraParams(), or is it just setting properties of the prim with llSetCameraAtOffset() and -EyeOffset() ?

Is the last argument passed to llTakeControls() TRUE or FALSE?

The position to which the camera snaps back when a movement key is pressed, is that the position the script sets (and you wanted the keys to do something different with the cam), or is it that the movement keys cause the cam to revert to normal behavior (and you wanted them to have no effect on the cam)?


Camera is indeed set with llSetCameraEyeOffset and llSetCameraAtOffset.

The last argument in TakeControls is FALSE.

The camera is snapped back to the llSetCameraEyeOffset and llSetCameraAtOffset, though I don't want them to affect camera at this point.

I tried different values for "accept" and "pass_on"... without noticeable effect.


RS
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-15-2009 05:40
I think what you want to do is pretty unlikely using just the prim's cam settings. Here's one ugly hack (and laggy, as shown, because of that evil tight timer; more on that forthwith):

CODE

integer PASS_ON_CONTROLS = FALSE;
float UPDATE_CAM_INTERVAL = 0.2; // EVIL!
key agent;

updateCam()
{
vector camPos = llGetCameraPos();
rotation camRot = llGetCameraRot();
llSetCameraParams(
[ CAMERA_POSITION, camPos
, CAMERA_POSITION_LOCKED, TRUE
, CAMERA_FOCUS, camPos + llRot2Fwd(camRot)
, CAMERA_FOCUS_LOCKED, TRUE
]);
}

default
{
state_entry()
{
// Just need to run this once to clear the prim's cam settings:
llSetCameraAtOffset(ZERO_VECTOR);
llSetCameraEyeOffset(ZERO_VECTOR);
// and to set a sit target (for llAvatarOnSitTarget())
llSitTarget(< 0.5, 0, 0.5 >, ZERO_ROTATION);
}
changed(integer change)
{
if (! (CHANGED_LINK & change))
return;
agent = llAvatarOnSitTarget();
if (NULL_KEY == agent)
{
llSetTimerEvent(0);
llReleaseControls();
llReleaseCamera(agent);
return;
}
llRequestPermissions(agent, 0
| PERMISSION_TAKE_CONTROLS
| PERMISSION_TRACK_CAMERA
| PERMISSION_CONTROL_CAMERA
);
}
run_time_permissions(integer perm)
{
llTakeControls( 0
| CONTROL_FWD
| CONTROL_BACK
| CONTROL_LEFT
| CONTROL_RIGHT
| CONTROL_ROT_LEFT
| CONTROL_ROT_RIGHT
| CONTROL_UP
| CONTROL_DOWN
| CONTROL_LBUTTON
| CONTROL_ML_LBUTTON
, TRUE, PASS_ON_CONTROLS);
llSetCameraParams(
[ CAMERA_ACTIVE, TRUE
, CAMERA_FOCUS, llGetPos() // wherever -AtOffset() may have pointed
, CAMERA_FOCUS_LOCKED, TRUE
, CAMERA_POSITION, llGetPos() + < 10.0, 0, 10.0 >*llGetRot()
, CAMERA_POSITION_LOCKED, TRUE
]);
llSetTimerEvent(UPDATE_CAM_INTERVAL);
}
control(key id, integer level, integer edge)
{
updateCam();
llOwnerSay("Control level = "+(string)level+", edge="+(string)edge);
}
timer()
{
updateCam();
}
}


The script exhibits an interesting behavior that I can't explain (and another that I can) if that timer is omitted. The easy one is that without the timer, the default cam position remains wherever it was when the last control event occurred, so pressing Escape will return the cam to that location rather than just leaving it be (the way it works with the timer).

The part I don't understand is that without the timer, the cam jumps around--tries to move with the movement keys and flips back where it belongs--but only until the second edge event. No idea what's happening with that.

A possibly fatal limitation is that this slaves the "default" cam to wherever the user moves the cam, so hitting Escape won't return it to anywhere else. (Would be a joyous day if we could ever register to get that Escape key as a control event.)
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
07-15-2009 12:31
I use a hudlet to freeze the camera, very simple script. It works fine, but doesn't take controls. It works fine even when sitting on an object with a script that takes controls.

So, I'm guessing there's a problem/bug if the same script or object does both. (Either that, or this is a new bug; I haven't used my hudlet in a month or two -- and I am running a rather old viewer.)

IM me ingame for a copy of the freezview hudlet, which might be helpful for testing or something.