Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with controling a car normaly in 1st person veiw

Pinto Schnyder
Registered User
Join date: 23 May 2007
Posts: 17
06-30-2007 23:43
Hello I was wondering if anyone knew what kind of script to use for 1st person controls with standard turning not straffing
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-01-2007 03:41
The problem I think is being raised here is that there seems to be no way to generate a CONTROL_ROT_LEFT or _ROT_RIGHT event while in Mouselook, but instead, the left and right arrow keys (and "A" and "D" keys) generate the CONTROL_LEFT and _RIGHT events, which are generally produced by a Shift key combination when not in Mouselook.

So, in Mouselook, if no special handling is provided, only "strafing" is produced. It is possible to detect that the avatar is in Mouselook (if AGENT_MOUSELOOK & llGetAgentInfo(av)), so in that case one could redefine the CONTROL_LEFT and _RIGHT keys to mimic the non-Mouselook behavior of _ROT_LEFT and _ROT_RIGHT, but I know of no way in Mouselook to get both "rotation" and "strafing" without the user explicitly activating some sort of mode toggle.

(If the problem is actually something different, sorry for the digression.)
Pinto Schnyder
Registered User
Join date: 23 May 2007
Posts: 17
07-01-2007 18:56
I know there is a way to do it cause there is a hover car called the Sim Racer that does this.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-01-2007 19:08
From: Pinto Schnyder
I know there is a way to do it cause there is a hover car called the Sim Racer that does this.
What does it do, exactly? As described, it's a trivial change to the script to make the Mouselook arrow keys cause rotation *instead of* "strafing." The problem is being able to do *both* in Mouselook without a mode switch (or perhaps nonstandard use of some other control key input). If Sim Racer somehow does both rotation and strafing in Mouselook, what is the user action that causes the different actions?
Pinto Schnyder
Registered User
Join date: 23 May 2007
Posts: 17
07-01-2007 20:12
Well the car i'm working on doesn't need straff just rotation so is there a variable I can change to make this possible?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-02-2007 00:04
Unless it's a very special vehicle script, it won't just be a variable change, but rather a bit of change to the handling of control input. There's likely a long sequence of if/else statements in the script, some of which handle the inputs for CONTROL_LEFT and CONTROL_RIGHT (to do strafing). To make the vehicle rotate instead of strafe, the logic should change so that both CONTROL_LEFT and CONTROL_ROT_LEFT do what CONTROL_ROT_LEFT does now, and the same for _RIGHT. Ideally this would be done by changing the "if" conditions, but it should work to just replace the block of code that's used for CONTROL_LEFT with a copy of that used for CONTROL_ROT_LEFT, and the same for _RIGHT.
Llyr Carter
Registered User
Join date: 29 Apr 2007
Posts: 1
extract from my script (still in development)
07-03-2007 01:26
Here is an extract from a script that Im creating now... I think this is what you are talking about ... although I am having troubles of my own with the car randomly jumping into the air and spinning all over the place.

if(change & CONTROL_ML_LBUTTON)
{
if(held & CONTROL_ML_LBUTTON)
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,<0,0,5>);
llSetVehicleFlags(VEHICLE_FLAG_MOUSELOOK_STEER);
}
else
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,<0,0,0>);
llRemoveVehicleFlags(VEHICLE_FLAG_MOUSELOOK_STEER);
}

}
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
07-03-2007 02:09
You can use a bitwise "or" on the flags you are checking to get either condition. So...

if ( held & CONTROL_LEFT )

becomes

if ( held & ( CONTROL_LEFT | CONTROL_ROT_LEFT ) )
Fenix Eldritch
Mostly harmless
Join date: 30 Jan 2005
Posts: 201
07-03-2007 06:11
Just a thought... could it be possible to "fake" mouselook by having the camera zoomed in and positioned just right? I'm not able to get inworld and test but try something like that.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
07-03-2007 06:30
You could set the camera to be inside the car by default, even when not in mouselook, though you could also force someone into mouselook when they sit down by default too.