11.07.2015 Views

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

Linden Scripting Language Guide - Engineering Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 11. VehiclesSo a typical Second Life vehicle is an object that exhibits linear and/or angular deflection along the "preferentialaxes of motion". The default preferential axes of motion are the local x- (at), y- (left), and z- (up) axes of thelocal frame of the vehicle’s root primitive. The deflection behaviors relate to the x-axis (at): linear deflection willtend to rotate its velocity until it points along it’s positive local x-axis while the angular deflection will tend toreorient the vehicle such that it’s x-axis points in the direction that it is moving. The other axes are relevant tovehicle behaviors that are described later, such as the vertical attractor which tries to keep a vehicle’s local z-axispointed toward the world z-axis (up). The vehicle axes can be rotated relative to the object’s actual local axes byusing the VEHICLE_REFERENCE_FRAME parameter, however that is an advanced feature and is covered indetail in a later section of these documents.Depending on the vehicle it might be desirable to have lots of linear and/or angular delfection or not. The speedof the deflections are controlled by setting the relevant parameters using the llSetVehicleFloatParam script call.Each variety of deflection has a "timescale" parameter that determines how quickly a full deflection happens.Basically the timescale it the time coefficient for exponential decay toward full deflection. So, a vehicle thatdeflects quickly should have a small timescale. For instance, a typical dart might have a angular deflectiontimescale of a couple of seconds but a linear deflection of several seconds; it will tend to reorient itself before itchanges direction. To set the deflection timescales of a dart you might use the lines below:llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2.0);llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 6.0);Each variety of deflection has an "efficiency" parameter that is a slider between 0.0 and 1.0. Unlike the otherefficiency parameter of other vehicle behaviors, the deflection efficiencies do not slide between "bouncy" and"damped", but instead slide from "no deflection whatsoever" (0.0) to "maximum deflection" (1.0). That is, theybehave much like the deflection timescales, however they are normalized to the range between 0.0 and 1.0.11.6. Moving the VehicleOnce enabled, a vehicle can be pushed and rotated by external forces and/or from script calls such asllApplyImpulse, however linear and angular motors have been built in to make motion easier and smoother.Their directions can be set using the llSetVehicleVectorParam call. For example, to make the vehicle try to moveat 5 meters/second along its local x-axis (the default look-at direction) you would put the following line in yourscript:llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, );To prevent vehicles from moving too fast the magnitude of the linear motor is clamped to be no larger than about30 meters/second. Note that this is clamped mostly because of limitations of the physics engine, and may beraised later when possible.29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!