Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Camera follower flips around wildly

Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-12-2009 12:03
I've got a script I've been using to get a drone to follow my camera. Works well. I'll show it below, along with the other one I mention.

However, I've put this in a little robot. When I use it though, it flips around wildly, no sense of direction, nothing. A workaround I used was to drop a second script in to make it face the nearest avatar. That's fine... But it makes me use a rotated prim as the base prim, because the lookat script makes the top of the object flip to face the nearest avatar, not the "forward" axis. Any idea how to add something to this script to make it face the direction it's traveling in, or to get my llLookAt script to stop using the "top" of the prim as the forward face?

This is the camera following script.

CODE


integer channel = 0;

default {
state_entry() {
llRequestPermissions(llGetOwner(),PERMISSION_TRACK_CAMERA);
}
run_time_permissions(integer perm) {
if (perm & PERMISSION_TRACK_CAMERA) {
state camera_captured;
}
}

on_rez(integer start_param)
{
// Reset script when the object is rezzed
llResetScript();
}
}


state camera_captured {
state_entry() {
llSetStatus(STATUS_PHYSICS,TRUE);
llSetTimerEvent(0.1);
}
timer() {
llMoveToTarget(llGetCameraPos() + < 1.5, 0.0, -0.2 > * llGetCameraRot(),0.1);
}

on_rez(integer start_param)
{
// Reset script when the object is rezzed
llResetScript();
}
}



And this is the llLookAt script I'm using.

CODE


//Causes Object to look at nearest Avatar.
default
{
state_entry()
{
llSensorRepeat("", "", AGENT, 100.0, PI, 0.2);
}

sensor(integer total_number)
{
vector them = llDetectedPos( 0 );
vector me = llGetPos();
llLookAt( < them.x, them.y, me.z >, 0.5, 0.5 );
}
}

_____________________
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-12-2009 15:16
Use the solution I gave in the other thread you started, it works and llRotLookAt does not use the TOP of the prim but the forward direction
_____________________
From Studio Dora
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-12-2009 15:18
Figured that out a few minutes ago, yes. Thanks, makes a big difference
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-12-2009 19:40
this is the script I'm using in my own physical cam follower
CODE

default{
state_entry(){
llRequestPermissions( llGetOwner(), PERMISSION_TRACK_CAMERA );
}

run_time_permissions( integer vBitPrm ){
if (PERMISSION_TRACK_CAMERA & vBitPrm){
llSetTimerEvent( 1.0 );
}
}

timer(){
llRotLookAt( llEuler2Rot( < 0.0, PI_BY_TWO, PI > ) * llGetCameraRot(), .5, 1.0 );
llMoveToTarget( llGetCameraPos() + < 1.0, 0.0, -0.5 > * llGetCameraRot(), 0.5 );
}
}

the llEuler2Rot call is just a correction for my non zero aligned root prim. I skipped the not at rot target event because it fails for zooming, and I didn't want to use two different events to control the movement and rotation (but you could, to make it faster on the response)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -