# Anti-Fall/Flip Robot/Vehicle

Please take a moment to consider if this thread is worth bumping.

## Recommended Posts

I have a robot that i can sit on (formed of 5 prims) that rotates and moves forward/backward along the Z axis.  It is basically a 1 speed vehicle in that sense.

But - sometimes, if it makes contact with a boundary wall it will "fall over" or "flip entirely over 180 degrees"

To fix it I have to go into EDIT and fix the rotation for X and Y back to Zero.

Is there a way to either always have X and Y rotations always be zero, or a rotation sensor to check for anything "not zero" and make it zero?

Thank you for any pointers.  Scripting is Amazingly fun and I'm brute-forcing trying things for a solution, but so far no success.

Mwuah,  Submissa. 😁

##### Share on other sites

Actually There is an easy fix! (I think ,can never say 100% without looking right at the script and build)

Take a look at the (unhelpfully named) llSetStatus() function, particularly the parameters STATUS_ROTATE_*.

If your robot needs to go uphill though, you might need fancy solutions, like raycasting a line below the robot, checking the hit normal, then something like

```llSetAngularVelocity(Magnitude*llRot2Euler(llRotBetween(RobotUp,DetectedNormal)),FALSE);
// where RobotUp is something like llRot2Up(llGetRot()); but will depend on your exact build, and
//   Detected Normal is the normal vector recieved from the raycast.
// Magnitude would have to be found by expiramentation, and the 'best' value might change depending
//   on the timer's frequency.```

on a timer.

Edited by Quistess Alpha
use AngularVelocity, not Torque.
• 1
##### Share on other sites

You can block physical object rotation around specific axes via llSetStatus, with STATUS_ROTATE_X, _Y and _Z.

• 1
##### Share on other sites

Ohhhh  thank you both!   Those look like juicy good solutions!  YUM.  The movement surface is thankfully a level plane so no climbing (YAY!)

##### Share on other sites

You might also look into the vertical attractor in vehicle functions.

```llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1.0);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.1);```

Will force it upright.

Edited by arton Rotaru
• 1
##### Share on other sites

Oh so many great tips!  This is truly a kind and wise community.  thank you

• 1