Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vehicle bumping into objects

Moe Lovenkraft
Registered User
Join date: 4 Nov 2007
Posts: 7
03-07-2008 02:11
I have a vehicle similar to a helicopter that has banking behaviour. When the vehicle bumps into something it's Y-axis beocomes tilted, like if I manage to land on something with the forward part of the helicopter the heli will tilt backwards and will then maintain this tilt unless given another impulse to straighten it like if I land on a flat surface.

What is the best way to deal with this? The banking behaviour will straighten the vehicle along the X-axis using VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY and VEHICLE_VERTICAL_ATTRACTION_TIMESCALE but the Y-axis will remain tilted. I'm experimenting with a script on a timer that will straighten the vehicle on the Y-axis but there must be some simpler way as this must be a common problem. I'm thinking on forcing the Y-axis rotation to zero, but I fear the vehichle will get stuck in objects that way.

Any ideas?
Taeas Stirling
Registered User
Join date: 4 Sep 2004
Posts: 74
03-08-2008 12:32
Make sure you have this line in your code. It tells the script how the vehicle should settle out after a bump or control change
llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
Moe Lovenkraft
Registered User
Join date: 4 Nov 2007
Posts: 7
03-10-2008 06:31
Thank you a lot, will try that.
Moe Lovenkraft
Registered User
Join date: 4 Nov 2007
Posts: 7
04-28-2008 04:22
The line above worked, but only before havoc 4. Does anyone have any ideas how to solve the problem?

I have an idea to use 'LlRotLookAt' and rotate the vehicle to make it stay level on the y-axis, but there seems to be no way of just rotating it along the y-axis or is there?
Moe Lovenkraft
Registered User
Join date: 4 Nov 2007
Posts: 7
05-06-2008 02:06
Anyone?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-06-2008 09:15
From: Moe Lovenkraft
I have an idea to use 'LlRotLookAt' and rotate the vehicle to make it stay level on the y-axis, but there seems to be no way of just rotating it along the y-axis or is there?

Well, you can calculate a rotation that is different only by a rotation about the y-axis (if the vehicle is only pitched up from horizontal). This function keeps the current forward (local x-axis) pointed as much in the same horizontal direction as possible but levels it and the y-axis:

CODE

rotation calculateHorizontalRot()
{
rotation currRot = llGetRot();
vector currX = llRot2Fwd(currRot);

vector newX;
if (1.0-llFabs(currX.z) < 0.01)
{
// Straight up/down; "pitch" to horizontal
if (currX.z > 0.0)
{
newX = -llRot2Up(currRot);
} else
{
newX = llRot2Up(currRot);
}
} else
{
newX = llVecNorm(<currX.x, currX.y, 0.0>);
}

vector newY = <-newX.y, newX.x, 0.0>;

return llAxes2Rot(newX, newY, <0.0, 0.0, 1.0>);
}
Moe Lovenkraft
Registered User
Join date: 4 Nov 2007
Posts: 7
05-07-2008 02:10
Thank you, I will try that. Trickier than they seem these rotations.