Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

FollowCam Question

Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-15-2006 18:14
I am trying to get a camera positioned in front of me and facing me with a follow distance of 3. I have the following so far but whatever I attempt to work in it always ends up behind me. Any ideas?

CODE
camera()
{
vector my_pos = llGetPos();
vector cam_pos = my_pos + (llRot2Fwd(llGetRot()) * 3);

llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_BEHINDNESS_ANGLE, 0.0,
CAMERA_BEHINDNESS_LAG, 0.0,
//CAMERA_DISTANCE, 3.0,
CAMERA_FOCUS, my_pos,
CAMERA_FOCUS_LAG, 0.0 ,
CAMERA_FOCUS_LOCKED, FALSE,
CAMERA_FOCUS_THRESHOLD, 0.0,
//CAMERA_PITCH, 80.0,
CAMERA_POSITION, cam_pos,
CAMERA_POSITION_LAG, 0.0,
CAMERA_POSITION_LOCKED, FALSE,
CAMERA_POSITION_THRESHOLD, 0.0,
CAMERA_FOCUS_OFFSET, ZERO_VECTOR
]);
}

default
{
attach(key id)
{
if (id != NULL_KEY)
{
llRequestPermissions(id, PERMISSION_CONTROL_CAMERA);
}
}

run_time_permissions(integer perm)
{
if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA)
{
llOwnerSay("Camera permissions have been taken");
camera();
}
}
}
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
03-15-2006 18:57
looks to me like your going about this a funny way. you're setting a static position at the time that the run time permissions are set. I've not played with FollowCam yet, so I could not comment on how to do what you're looking for, however that is how I see the problem you currently are facing.
Kelly Linden
Linden Developer
Join date: 29 Mar 2004
Posts: 896
03-15-2006 19:22
I think nand is right. You probably want to be setting CAMERA_FOCUS_OFFSET and not CAMERA_POSITION.

Also, if you want the camera to follow you, then you probably don't want to set CAMERA_FOCUS as that will set a static position I think? (I'm a newb to these controls as well.)
_____________________
- Kelly Linden
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-15-2006 20:36
I set CAMERA_FOCUS_OFFSET to <0,10,0> and the camera does go in front of the character but it does not face the character. So, it's half fixed. Even if I have CAMERA_FOCUS set to llGetPos() it still does not face me. Reporting llGetPos() shows my correct position in world so I know the vector coordinates are there. I also tried setting a touch event to re-issue the camera settings outside of the run_time_permissions and same effect of camera not facing AV. Is this even possible in a following camera scenario?

EDIT: I tried it without CAMERA_FOCUS also.

EDIT: Removed the other example I posted as it may be misleading the issue.
Kelly Linden
Linden Developer
Join date: 29 Mar 2004
Posts: 896
03-15-2006 20:47
It looks like you are still setting CAMERA_FOCUS_OFFSET to ZERO_VECTOR and that you have CAMERA_FOCUS set to cam_offset.

Try doing
CAMERA_FOCUS_OFFSET, <0,10,0>

And not including the CAMERA_FOCUS line at all. If no CAMERA_FOCUS line is specified then I think it follows the avatar around. I made a really simple fixed cam that stayed in one spot and always looked at my avatar with only a few parameters:
CAMERA_ACTIVE, 1
CAMERA_POSITION, cam_pos,
CAMERA_POSITION_LAG, 0.0,
CAMERA_POSITION_LOCKED, TRUE

In other words, you don't need to set all variables, and not setting some may be specifically what you want.
_____________________
- Kelly Linden
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-15-2006 20:54
From: Kelly Linden
It looks like you are still setting CAMERA_FOCUS_OFFSET to ZERO_VECTOR and that you have CAMERA_FOCUS set to cam_offset.


Sorry for the confusion but the 2nd example I posted was not for the original question. It was just to show some other example I setup if anyone was interested since it works for what it's supposed to do. The 1st script I posted is the problem I am having and is unable to accomplish what I am trying to do.

Let me note again though that I commented out CAMERA_FOCUS and set CAMERA_FOCUS_OFFSET to <0,3,0> (or <3,0,0> maybe was the one) and the camera goes into front but it does not face the character.
Kelly Linden
Linden Developer
Join date: 29 Mar 2004
Posts: 896
03-15-2006 21:03
Oops. Sorry. :D
_____________________
- Kelly Linden
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-15-2006 21:09
From: Kelly Linden
Oops. Sorry. :D

Hehe. That was totally my fault. No problem. ;) Ok, here is another clear example of what I have so far without much of the camera settings specified. If I comment CAMERA_FOCUS out, there is no difference. Touching it to reset the camera settings outside run_time_permissions() has no effect also.

CODE
camera()
{
vector my_pos = llGetPos();

llClearCameraParams();

llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_FOCUS, my_pos,
CAMERA_FOCUS_OFFSET, <10,0,0>
]);
}

default
{
attach(key id)
{
if (id != NULL_KEY)
{
llRequestPermissions(id, PERMISSION_CONTROL_CAMERA);
}
}

run_time_permissions(integer perm)
{
if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA)
{
llOwnerSay("Camera permissions have been taken");
camera();
}
}

touch_start(integer num_detected)
{
camera();
}
}


Camera goes in front of me but does not face me.
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-15-2006 21:59
This is the closest thing I could come up with so far. The only thing it lacks is the ability to follow your turn so that it is always in line of the direction you are viewing.
CODE
float camera_distance = 3.0;

camera()
{
vector my_pos = llGetPos();
vector offset = my_pos + (llRot2Fwd(llGetRot()) * camera_distance);

llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_POSITION, offset,
CAMERA_FOCUS, my_pos,
CAMERA_BEHINDNESS_ANGLE, 180.0,
CAMERA_DISTANCE, camera_distance
]);
}

default
{
attach(key id)
{
if (id != NULL_KEY)
{
llRequestPermissions(id, PERMISSION_CONTROL_CAMERA);
}
}

run_time_permissions(integer perm)
{
if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA)
{
llOwnerSay("Camera permissions have been taken");
camera();
}
}
}
_____________________
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
03-16-2006 10:59
From what I can tell from playing with the camera stuff today, you just can't do what you're trying to do here. The thing is, you can set the camera in front of you and pointing back at you fine, but the camera position setting won't "stick" as a relative position offset from your avatar. What I mean is, you can move, but the camera will stay where you set it until your avatar drags it away and the CAMERA_FOCUS starts dragging your camera along with your av. From then on, your camera will just be following along.

The only way I found to fix this was to set up a timer and continually call llSetCameraParams() to update the camera position as the av moves. It's ugly, and it tends to get into fights between positioning based on CAMERA_POSITION and FOCUS_POSITION/CAMERA_DISTANCE. From what I can tell, there is no built-in way to make the camera follow along in front of your av looking back at it, or beside your av looking toward it, without continually manually updating the camera position.
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
03-16-2006 11:44
Yea :( Pretty much what I am finding out also. Perhaps something they could add in the future. It would be nice for like different camera angles when like flying or for machinima.