DarkEmperor13 Posted December 31, 2020 Share Posted December 31, 2020 Here's my script: float gMaxTurnSpeed = 12; float gMaxWheelieSpeed = 5; float gMaxFwdSpeed = 30; float gMaxBackSpeed = -10; float gAngularRamp = 0.17; float gLinearRamp = 0.2; // These are true globals whose values are "accumulated" over // multiple control() callbacks. float gBank = 0.0; vector gLinearMotor = <0, 0, 0>; vector gAngularMotor = <0, 0, 0>; default { state_entry() { // init stuff that never changes llListen(19864, "", llGetOwner(), ""); llSetSitText("Ride"); llCollisionSound("", 0.0); llSitTarget(<-0,0.0,-.1>,llEuler2Rot(<0.0,0.0,0>*DEG_TO_RAD)); llSetCameraEyeOffset(<-6.0, 0.0, 1.0>); llSetCameraAtOffset(<3.0, 0.0, 1.0>); // create the vehicle llSetVehicleFlags(-1); llSetVehicleType(VEHICLE_TYPE_CAR); llSetVehicleFlags(VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.1); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.1); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1); llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000, 100, 1000>); llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <500, 500, 1000>); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.50); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50); // llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 3.0); // llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.7); // llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.01); } changed(integer change) { if (change & CHANGED_LINK) { key agent = llAvatarOnSitTarget(); if (agent) { if (agent != llGetOwner()) { // owner has mounted llSay(0, "You aren't the owner"); llUnSit(agent); llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE); } else { llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DRIVING", NULL_KEY); llSleep(.4); // not the owner ==> boot off llSetStatus(STATUS_PHYSICS, TRUE); llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS); // reset the global accumulators gAngularMotor = <0, 0, 0>; gLinearMotor = <180, 0, 0>; gBank = 0.0; } } else { // dismount llSetStatus(STATUS_PHYSICS, FALSE); llSleep(.1); llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DEFAULT", NULL_KEY); llSleep(.4); llReleaseControls(); llStopAnimation("motorcycle_sit"); llStopSound(); //llPlaySound("off", 0.4); } } } run_time_permissions(integer perm) { if (perm) { llStartAnimation("car sit"); llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP, TRUE, FALSE); } } control(key id, integer level, integer edge) { // The idea here is to ramp up the motors when the keys are held down for a long // time and to let the motors decay after they are let go. This allows fine- // tuning of the motion of the vehicle by throttling the key controls. // // Note that this probably doesn't work well when the client FPS and/or the server // FPS is lagging. So for best results you'll want to turn off as much visual // effects as you can tolerate, and drive in the more empty areas. // linear integer key_control = FALSE; if(level & CONTROL_FWD) { llSetLinkPrimitiveParams(3,[PRIM_OMEGA, <0,-1,0>, 1, 1]); llSetLinkPrimitiveParams(20, [PRIM_OMEGA, <0,-1,0>, 1, 1]); llSetLinkPrimitiveParams(15, [PRIM_OMEGA, <0,1,0>, 1, 1]); llSetLinkPrimitiveParams(17, [PRIM_OMEGA, <0,1,0>, 1, 1]); gLinearMotor.x = gLinearMotor.x + gLinearRamp * (gMaxFwdSpeed - gLinearMotor.x); key_control = TRUE; } if(edge & CONTROL_FWD) { llSetLinkPrimitiveParams(3,[PRIM_OMEGA, <0,0,0>, 1, 1]); llSetLinkPrimitiveParams(20, [PRIM_OMEGA, <0,0,0>, 1, 1]); llSetLinkPrimitiveParams(15, [PRIM_OMEGA, <0,0,0>, 1, 1]); llSetLinkPrimitiveParams(17, [PRIM_OMEGA, <0,0,0>, 1, 1]); } if(level & CONTROL_BACK) { gLinearMotor.x = gLinearMotor.x + gLinearRamp * (gMaxBackSpeed - gLinearMotor.x); key_control = TRUE; } if (key_control) { llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor); key_control = FALSE; } else { if (gLinearMotor.x > 15 || gLinearMotor.x < -5) { // Automatically reduce the motor if keys are let up when moving fast. gLinearMotor.x *= 0.8; llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor); } else { // reduce the linear motor accumulator for the next control() event gLinearMotor.x *= 0.8; } } // angular if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) { gAngularMotor.x = gAngularMotor.x + gAngularRamp * (gMaxTurnSpeed - gAngularMotor.x); key_control = TRUE; } if(level & (CONTROL_LEFT | CONTROL_ROT_LEFT)) { gAngularMotor.x = gAngularMotor.x - gAngularRamp * (gMaxTurnSpeed + gAngularMotor.x); key_control = TRUE; } if(level & CONTROL_UP) { gAngularMotor.y = gAngularMotor.y - gAngularRamp * (gMaxWheelieSpeed + gAngularMotor.y); key_control = FALSE; } if (key_control) { // turn on banking and apply angular motor gBank = 3.0; llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, gBank); llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,gAngularMotor); gAngularMotor *= 0.95; // light attenuation } else { if (gAngularMotor.x > 4 || gAngularMotor.x < -4) { // We were turning hard, but no longer ==> reduce banking to help // the motorcycle travel straight when bouncing on rough terrain. // Also, turn off the angular motor ==> faster upright recovery. gAngularMotor *= 0.4; gBank *= 0.5; llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, gBank); llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,gAngularMotor); } else { // reduce banking for straighter travel when not actively turning gAngularMotor *= 0.5; gBank *= 0.8; llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, gBank); } } } } // END // ok when i turn, the car turns like an airplane like the pic below. How do I fix it? Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 31, 2020 Share Posted December 31, 2020 Turn off banking. Unless you are making a motorcycle or an airplane or boat that needs to lean into the turn, you don't want banking. Link to comment Share on other sites More sharing options...
DarkEmperor13 Posted December 31, 2020 Author Share Posted December 31, 2020 i tried removing everything that dealt with banking but then my dang car wouldnt turn Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 31, 2020 Share Posted December 31, 2020 It looks to me like you are still adjusting VEHICLE_BANKING_EFFICIENCY. 1 Link to comment Share on other sites More sharing options...
arton Rotaru Posted December 31, 2020 Share Posted December 31, 2020 12 minutes ago, DarkEmperor13 said: i tried removing everything that dealt with banking but then my dang car wouldnt turn Well, if you want your vehicle to turn without banking, you need to apply the angular motor around the Z axis. 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 31, 2020 Share Posted December 31, 2020 6 minutes ago, arton Rotaru said: you need to apply the angular motor around the Z axis. I didn't even notice that. 👍 1 Link to comment Share on other sites More sharing options...
animats Posted January 1, 2021 Share Posted January 1, 2021 You've put a motorcycle script in a car. There are car scripts, or you can keep modifying what you've got until you get car-like behavior. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now