Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

"Vehicle" behavior

Static Sprocket
Registered User
Join date: 10 Feb 2006
Posts: 157
07-01-2006 16:11
From: Andrew Linden
That said, I doubt that is what you want for your vehicle. What you probably want is to use the 'vertical attactor' behavior, which tries to keep the Z-axis axis of the vehicle pointing toward the sky. If that is the case, don't mess with STATUS_ROTATE_XYZ. Instead, play with the VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY and VEHICLE_VERTICAL_ATTRACTION_TIMESCALE parameters.


Well... Actually, it's not a vehicle at all, but rather some A*Life fish.

I'm using the vehicle scripting because the VEHICLE_LINEAR_FRICTION_TIMESCALE and VEHICLE_ANGULAR_DEFLECTION_TIMESCALE greatly simplifies my scripting as well as does a wonderful job of generally smoothing out the fishes movement.

For the most part I have been using VEHICLE_VERTICAL_ATTRACTION_TIMESCALE with a setting of zero to clamp the fish vertically, and only allow rotation around the Z axis. I also removed VEHICLE_FLAG_LIMIT_ROLL_ONLY.

As the complexity of their behavior has grown, I now need the ability to pitch the fish forward, so that I can "eat" food off the ocean floor -- or inversely pitch the fish up, so that eat can eat food floating on the surface of the water.

I first tried using VEHICLE_FLAG_LIMIT_ROLL_ONLY, but that meant the fish would no longer "right" themselves and they ended up perpetually angled up or down, or spinning around on the local Y axis.

Then I removed that flag, and switched VEHICLE_VERTICAL_ATTRACTION_TIMESCALE to a non-zero value. This now corrects the fish, righting it after some time. Additionally I set VEHICLE_ANGULAR_FRICTION_TIMESCALE, <0, 4, 4> -- in hopes that it would prevent rotation around the X axis. However sometimes, usually as a result of a collision or a particularly large linear impulse, the fish will rotate around it's X axis. Which looks completely absurd.

So at this point, the behavior I'm seeing is the expected behavior, and if I want the ability to clamp the X rotation, so that it *never ever ever ever* happens, then that is a feature request? Or should the ROTATION_X_STATUS flag correctly clamp X rotation even when using physics and vehicle flags?

Thanks!!!
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
07-01-2006 17:29
Yes, rotations about the X axis can be achieved by combinations of rotations about local Y and Z, which is probably how your fish is getting into positions that look like it only rotated about X. This is equivalent to the 'rotations do not commut' property.

I really think disabling STATUS_ROTATION_X is NOT where you want to explore. The vehicle behavior will tend to 'fight' with that limitation causing very odd effects. Frustration lies down that path.

Here are my ideas:

(1) The asymmetric angular friction was a clever idea. It may be there is some magic vector between <0,4,4> and <4,4,4> that will be a good compromise that will allow the fish to eventually right itself about the X axis. Alternatively, you might have to dynamically set some of the vehicle parameters depending on the fish's current mode of behavior.

(2) It might be possible to balance a Y-only angular motor against the vertical attractor to achieve temporary angled orienations. Tweaking the parameters just right will probably be an excercise in patience.

(3) There is a little used feature of the vehicle behavior called the "VEHICLE_REFERENCE_FRAME". A long time ago I heard a few reports that it doesn't work correctly for some of the other behaviors, but didn't have time to look into it at the time, and then I haven't heard anything about it since. I doubt anyone is actually using it but... its purpose is to correct the 'local axes' of the vehicle. For instance, if you happened to build something with its root prim pointing the wrong way relative to the rest of the vehicle then you should be able to set the "EHICLE_REFERENCE_FRAME" to fix that problem.

It may be possible to use the "VEHICLE_REFERENCE_FRAME" to dynamically rotate the fish's frame such that its nose points up or down, and then rotate it back when its done. One catch is that the 'forward' direction of the fish will no longer be aligned with its nose.


Sounds like a vector value for "VEHICLE_VERTICAL_ATTRACTION_TIMESCALE", instead of a scalar, might provide the feature you're looking for. That way you could specify a weak response about Y but a strong one about X. Such a change wouldn't conflict with vehicles as they currently work, since setting all three values of the vector to the same value would have the same effect as a scalar. I'll keep it in mind for the next time I get a chance to revisit the vehicle code.