Basically the motorcycle behaves like this. Just go into mouselook, point in the direction you want to go and the bike will bank and turn in that direction dynamically. The next thing I want to do is to set up the bike so that the faster you go, the less grip you have on the tires, but the slower you go, the more grip you have on the tires. You know. Realistically. Do you have any ideas on how I can do this? I am not a good scripter and I could use help and or script examples.
Anyways. Here is the code.
CODE
//Kwipper's Vehicle Script (Modified from Cory Linden's Vehicle Script)
float forward_max_speed = 20;
float backward_max_speed = 20;
float boost_multiplier = 4; // the number here determines how much of a speed boost you get when you hit the boost
float tire_slippage = 1; //A slider that affects how much the tires will drift on the road making turns. (Higher numbers means more slippage)
float acceleration = 1; // controls the time it takes for the vehicle to accelerate to max speed when you step on the gas.
float deceleration = 10; // controls the time it takes for the vehicle to decelerate to a full stop when you let off the gas.
string sit_message = "Ride"; //The message that appears when you want to ride the vehicle
//Everything below here should only be modified by those experienced in scripting.
default
{
state_entry ()
{
llPassCollisions(TRUE);
llPassTouches(FALSE);
llSetSitText(sit_message);
llSitTarget(<0.6,0.0,0.25>, ZERO_ROTATION);
llSetCameraEyeOffset(<-7.0, 0.0, 1.0>);
llSetCameraAtOffset(<3.0, 0.0, 2.0>);
llSetVehicleType(VEHICLE_TYPE_CAR);
llSetVehicleFlags(VEHICLE_FLAG_CAMERA_DECOUPLED
| VEHICLE_FLAG_LIMIT_MOTOR_UP
| VEHICLE_FLAG_MOUSELOOK_STEER
| VEHICLE_FLAG_MOUSELOOK_BANK
);
llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_WATER_ONLY
| VEHICLE_FLAG_HOVER_TERRAIN_ONLY
| VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT
);
// least for forward-back, most friction for up-down
llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <100,tire_slippage,1000> );
//I commented this out because it doesn't seem to affect anything with the turning, or anything for that matter
//llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1000, 1000, 1000>);
// linear motor wins after about 1 second, decays after about a 10 seconds
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, acceleration );
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, deceleration );
// angular motor wins after zero seconds, decays in same amount of time
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,<4*PI,2*PI,0>);
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.06 );
//llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.06 );
// halfway linear deflection with timescale of 3 seconds
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 );
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 3 );
// angular deflection with a timescale of 5 seconds
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5 );
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 5 );;
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.3 );
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.5 );
llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 1 );
llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1 );
llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 0 );
// default rotation of local frame
llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
//if (agent != llGetOwner())
//{
// llSay(0, "You are not the owner of this vehicle. Please step away.");
// llUnSit(agent);
// llPushObject(agent,<0,0,10>, ZERO_VECTOR, FALSE);
//}
//else
{
llSetStatus(STATUS_PHYSICS, TRUE);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llWhisper(0,"Welcome to Kwipper's Mouselook Motorcycle");
llWhisper(0,"'W' Accelerates, 'S' Decelerates/Reverse.");
llWhisper(0,"'E' Emergency Brake");
llWhisper(0,"'Left Mouse Button' enables turbo boost");
llWhisper(0,"Steer by going into 'Mouselook View' looking in the direction you want to go while accelerating.");
}
}
else
{
integer p = llGetPermissions();
llSetStatus(STATUS_PHYSICS, FALSE);
if(p & PERMISSION_TAKE_CONTROLS)
{
llReleaseControls();
}
if(p & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("motorcycle_sit");
llWhisper(0,"Thank you for trying out Kwipper's Mouselook Motorcycle.");
llWhisper(0,"Let [Kwipper Manimal] know about your experience with this motorcycle");
llPushObject(agent,<0,10,10>, ZERO_VECTOR, FALSE);
}
}
}
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("motorcycle_sit");
llStartAnimation("motorcycle_sit");
}
if(perm & PERMISSION_TAKE_CONTROLS)
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT |
CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_ML_LBUTTON, TRUE, FALSE);
}
control(key id, integer level, integer edge)
{
if(level & CONTROL_FWD)
{
//A vector. It is the velocity (meters/sec) that the vehicle will try to attain. It points in the vehicle's local frame, and has a maximum length of 40.
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,<forward_max_speed,0,0>);
}
if(level & CONTROL_BACK)
{
//This sets the max velocity the vehicle will achive by meters/second
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,<-backward_max_speed,0,0>);
}
if(level & CONTROL_ML_LBUTTON)
{
//This sets the max speed of the turbo
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,<forward_max_speed*boost_multiplier,0,0>);
}
if(level & CONTROL_UP)
{
//This sets the emergency brake
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION,<0,0,0>);
}
}
}