Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

TargetOmega to stop point?

Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
05-12-2006 23:19
Hi All...

is there a function... of method of using one... like llTargetOmega that will rotate to a specific angle? I love how llTargetOmega works... but I only want a few degrees of rotation... then stop.

Any hlp appreciated
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
05-12-2006 23:51
llTargetOmega, being a client-side function, doesn't actually rotate objects, it just creates a special effect that makes it look like their rotating to the agents looking at it (unless the object is physical, apparently).

You'll probably have to actually rotate the object, using llSetRot(). Here's an example of one way to do this; this script rotates the object, when touched, 45 degrees around the z-axis, in 10 steps. You can change the number of degrees, the number of steps, the axis of rotation, and whether it does a local or global rotation, as you desire. :)

CODE
// Desired rotation in degrees.
float desired_rotation = 45.0 ;

// Number of steps to break the rotation down into.
integer steps = 10 ;

// Axis to rotate about.
vector rotation_axis = < 0, 0, 1 > ;

rotation rotation_step ;

// Set to TRUE if the object should rotate about its local axis,
// or set to FALSE to rotate around the global axis.
integer local = TRUE ;

default
{
state_entry()
{
// Divide the desired rotation by the number of steps, then convert this into
// a Euler rotation, then convert that into an actual quaternion rotation.
rotation_step = llEuler2Rot( rotation_axis * ( desired_rotation / (float)steps * DEG_TO_RAD ) ) ;
}

touch_start( integer num )
{
integer i ;

// Count through the number of desired steps.
for( i = 0; i < steps; i++ )
{
// Order of multiplication for rotations matters!

// If the rotation is set for local axes...
if( local ) llSetRot( rotation_step * llGetRot() ) ;

// Otherwise...
else llSetRot( llGetRot() * rotation_step ) ;
}
}
}
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
05-13-2006 10:21
You can try this:

/54/31/69230/1.html

It uses llTargetOmega and some careful timing to stop the spinning at the end and llSetRot() to match the new rotation. Works most of the time.
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
THx...
05-14-2006 09:20
THanks Lex...

The script works great... the motion is beautiful....

Except... It stopped working when I linked the object to the vehicle it is a part of.

Any fix for this?

I can't understand why it doesn't work after linking... is it a bug?