Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help With Vehicle Script

Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
07-13-2005 23:15
I've been attempting to build a vehicle script and have been digesting many of the free vehicle scripts out there. I can make a vehicle that moves, but not one that maintains x stability or floats on water--despite attempting to implement the supposed script commands for making these things possible. I know it's a lot to look through, but might someone look through the following initial code in my vehicle script and tell me what I might be doing wrong? Thank you.

vector linear = <0,0,0>;
vector angular = <0,0,0>;

default
{
state_entry()
{
llSetSitText("Surf";);

llCollisionSound("", 0.0);

llSitTarget(<0.3, 0.0, 1.0>, ZERO_ROTATION);
llSetCameraEyeOffset(<-9.0, -0.00, 4.0>;);
llSetCameraAtOffset(<3.0, 0.0, 2.0>;);

llSetVehicleType(VEHICLE_TYPE_BOAT);


llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <50.0, 100.0, 0.0>;);
llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 50.0);

llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <10.0,10.0,10.0>;);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 10.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 1.0);

llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <50, 50, 50>;);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 2.0);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 1.0);

llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0.0);
llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, .9);
llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0.0);

llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0);

llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 120.0);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, .10);

llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, .5);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, .95);

llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.25);
llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1.0);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 3.0);

llSetVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY);

llSetStatus(STATUS_PHYSICS, FALSE);
}
Kairen Overdrive
Registered User
Join date: 12 Jul 2005
Posts: 38
07-14-2005 03:31
It should be the buoyancy that affects if it floats..just experiment with that.

I hope that is only a part of the code because if that is all that is in the code you need to tell it that it should move when you press a key relatively..

Look at the vehicle scripts in this forum closer, somewhere further down there are parts which declare that if you press forward you move forward etc.
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
07-14-2005 17:09
I believe HoverHeight should be set to something other than 0, othewise it will either sink, or remain bouyant(if bouyancy is set at 1.0) at whatever height your vehicle is at when a user selects "SURF".

Also, by only using bouyancy, you risk that your vehicle will end up at a different height than you desire by colliding with other things.

I'm not a vehicle expert, but I think that info should help

here is some infor taken from the wiki http://secondlife.com/badgeo/wakka.php?wakka=LindenVehicleTutorial
From: someone

**************************************************************
11.13. Buoyancy

The vehicle has a built-in buoyancy feature that is independent of the llSetBuoyancy call. It is recommended that the two buoyancies do not mix! To make a vehicle buoyant, set the VEHICLE_BUOYANCY parameter to something between -1.0 (extra gravity) to 1.0 (full anti-gravity).

The buoyancy behavior is independent of hover, however in order for hover to work without a large offset of the VEHICLE_HOVER_HEIGHT, the VEHICLE_BUOYANCY should be set to 1.0.

It is not recommended that you mix vehicle buoyancy with the llSetBuoyancy script call. It would probably cause the object to fly up into space.

*******************************************************************
11.14. Hover

The hover behavior is enabled by setting the VEHICLE_HOVER_TIMESCALE to a value less than 300 seconds; larger timescales totally disable it. Most vehicles will work best with short hover timescales of a few seconds or less. The shorter the timescale, the faster the vehicle will slave to is target height. Note, that if the values of VEHICLE_LINEAR_FRICTION_TIMESCALE may affect the speed of the hover.

Hover is independent of buoyancy, however the VEHICLE_BUOYANCY should be set to 1.0, otherwise the vehicle will not lift itself off of the ground until the VEHICLE_HOVER_HEIGHT is made large enough to counter the acceleration of gravity, and the vehicle will never float all the way to its target height.

The VEHICLE_HOVER_EFFICIENCY can be thought of as a slider between bouncy (0.0) and smoothed (1.0). When in the bouncy range the vehicle will tend to hover a little lower than its target height and the VEHICLE_HOVER_TIMESCALE will be approximately the oscillation period of the bounce (the real period will tend to be a little longer than the timescale).

For performance reasons, until improvements are made to the Second Life physics engine the vehicles can only hover over the terrain and water, so they will not be able to hover above objects made out of primitives, such as bridges and houses. By default the hover behavior will float over terrain and water, however this can be changed by setting some flags:

If you wanted to make a boat you should set the VEHICLE_HOVER_WATER_ONLY flag, or if you wanted to drive a hover tank under water you would use the VEHICLE_HOVER_TERRAIN_ONLY flag instead. Finally, if you wanted to make a submarine or a balloon you would use the VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT. Note that the flags are independent of each other and that setting two contradictory flags will have undefined behavior. The flags are set using the script call llSetVehicleFlags().

The VEHICLE_HOVER_HEIGHT determines how high the vehicle will hover over the terrain and/or water, or the global height, and has a maximum value of 100 meters. Note that for hovering purposes the "center" of the vehicle is its "center of mass" which is not always obvious to the untrained eye, and it changes when avatar's sit on the vehicle.
_____________________
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
07-14-2005 23:11
Thanks for the help from both of you :) Yes, I do have more to the script, there's nothin' to worry about there...

...it had to do with the hover at zero. Thank you much.