Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Simple Toggling 1st person camera script

Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
03-27-2006 13:27
I wrote a simple script using the camera system that when you say "/2 front cam" it goes into an interactive first person view, and when you say "/2 normal cam" it goes back to normal. This is very simple, so I wont leave any license or something like that. Here it is :D

CODE

camera()
{
llSetCameraParams([
CAMERA_ACTIVE, TRUE,
CAMERA_POSITION, llGetPos(),
CAMERA_DISTANCE, 0.0,
CAMERA_POSITION_LAG, 0.0,
CAMERA_POSITION_THRESHOLD, 0.0,
CAMERA_BEHINDNESS_ANGLE, 0.0,
CAMERA_BEHINDNESS_LAG, 0.0,
CAMERA_FOCUS_LAG, 0.0,
CAMERA_FOCUS_THRESHOLD, 0.0,
CAMERA_FOCUS_OFFSET, <1,0,1>
]);
}

default
{
state_entry()
{
llClearCameraParams();
llListen(2,"",llGetOwner(),"");

}
listen( integer channel, string name, key id, string message )
{
if (message == "front cam")
{
llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
llOwnerSay("1st person camera activated");
}


if (message == "normal cam")
{
llOwnerSay("Camera back to normal.");
llClearCameraParams();
llResetScript();
}
}
run_time_permissions(integer perm)
{
if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA)
{
camera();
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
03-27-2006 21:28
/15/63/96443/1.html#post958449
_____________________
i've got nothing. ;)
Mikey Dripp
Registered User
Join date: 5 Dec 2005
Posts: 26
04-05-2006 16:29
Is there a way to set the parameters so that the camera looks at me from off to the side, as I move around? Or from my front? Or maybe from overhead? In other words, to not have the camera always be looking at the back of my head!! This would be as I move around in the world, not just in a particular building. Thanks!
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
04-05-2006 16:50
There is a script in the scripting librrary that someone made which allows you to have a movie-based camera. It moves away from buildings, and won't get stuck in things.
Mikey Dripp
Registered User
Join date: 5 Dec 2005
Posts: 26
04-06-2006 12:27
One I've found that works well is the overhead cam, it only needs these:

CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
CAMERA_PITCH, 80.0, // (-45 to 80) degrees

The distance tells how high it is, and the pitch controls how directly overhead it is. 80 degrees is the maximum which is almost straight overhead. This stays above me as I move around.

I've also had fun with this combination:

CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_POSITION, llGetPos() + <0,0,5>, // region relative position
CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)

This creates a fixed position overhead camera that always aims at me as I move around. It's really fun to watch myself run and jump, fly and land, from a different angle. Usually I only get to see other people like that. Plus you can set the position offset as high or as far as you like, so you can see a huge area if you want. You aren't limited to 10 meters like with the moving camera.

I get the impression that some combinations of parameters don't make sense. Like if you set CAMERA_POSITION_LOCKED to TRUE, I don't think CAMERA_DISTANCE or CAMERA_PITCH matter. Probably not the BEHINDNESS stuff or the other CAMERA_POSITION_ ones either. I need to experiment with these more.