Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How can I make an airbourne/flipped car act like one?

Redd Shelman
Registered User
Join date: 6 Jul 2008
Posts: 5
04-19-2009 04:47
Is it possible to make a car unable to move while in the air or/and when the wheels are not touching the floor? If so, could I get a script to add.. or just a hint to how to make it?

I'm used to all of the cheap car codes, you see. :( Can't find search keywords that work either.
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
04-19-2009 07:47
Check out the flag VEHICLE_FLAG_LIMIT_MOTOR_UP:

(copied from )
From: someone
Prevents ground vehicles from motoring into the sky. This flag has a subtle effect when used with conjunction with banking: the strength of the banking will decay when the vehicle no longer experiences collisions. The decay timescale is the same as VEHICLE_BANKING_TIMESCALE. This is to help prevent ground vehicles from steering when they are in mid jump.

This means when VEHICLE_FLAG_LIMIT_MOTOR_UP is set, the vehicle's motor will not push when the object has ceased to be receiving any collisions (i.e. airborne), and its ability to turn will drop off as well, the longer it's in the air. This is automatically set for VEHICLE_TYPE_CAR... but if you are using that type already, your script may be clearing it. These are the default flags for VEHICLE_TYPE_CAR:

llSetVehicleFlags( VEHICLE_FLAG_NO_DEFLECTION_UP
| VEHICLE_FLAG_LIMIT_ROLL_ONLY
| VEHICLE_FLAG_LIMIT_MOTOR_UP );

Car reference:
Linden Vehicle Tutorial:

You might also want to look at the control() event code to make sure that your "cheap car codes" are not using an impulse or other non-motor method to propel it. ;)
~Boss
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
Inverted vehicle brainstorming (YMMV)
04-19-2009 09:27
If you want to also stop moving when you're simply inverted and not airborne, that's a bit more complex. You might have to use the Collision events (see ) to set a flag or tell the control code not to drive the vehicle when the collision() and land_collision() events have stopped happening for the wheel prims (you can either put this into the wheel prim scripts, sending a linked message when they have timed out, or by using llDetectedLinkNumber() inside of collision_end() and land_collision_end() events, checking for the wheel prim link numbers, but this may bog down your main script, as there are a LOT of collision events while a car is moving. There's also a problem with the *collision_end() events not firing at times, or perhaps coming in before the last *collision() event.

Offhand I would probably put a timer in the roof prim (it's just one to check instead of multiple wheels), which checks for the root prim being upside down whenever a roof collision event is triggered with either land or prims, in that roof prim. (You probably don't want people stopping your vehicle by standing on or dropping things on it.) That script can then tell the motor control code to stop pushing while that condition exists.

I've never really tested it in Havok4... but another idea is to make the roof and side prim materials "stone" and the wheel prim materials "glass", and then the greater friction of the roof should slow you down when inverted if your motor is tuned to allow that, but it won't stop you altogether unless your motor is rather weak and the roof prim is large and flat. Designing your vehicle so it tips somewhat forward when inverted should enhance this effect too.
~Boss
Redd Shelman
Registered User
Join date: 6 Jul 2008
Posts: 5
04-20-2009 08:30
Thanks for all of that.

With my current scripts and every other car I've had, I can rez it, put it up into the air a few metres and it flies forward in a nosedive. That's probably the real problem, though I still get turn control in midair.

The roof thing is a bit more complex for me then you'd expect - I'm making Battlebots. Didn't want to have to say so. Quite technical prim-wise, and all of those different shapes. ^^;