• 0

# How to set a object to rot using LSL?

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

## Question

Hi! Guys! Do you know how to set a object in SL to rot using LSL?I have used the function llSetRot() and llGetLinkPrimitiveParams( link_number, [ PRIM_ROTATION ,<0,0,1,0.1>],But the object only rot once.

## Recommended Posts

• 0

The full discussion can be found here on the rotation options via LSL scripting:

http://wiki.secondlife.com/wiki/Rotation

http://wiki.secondlife.com/wiki/LSL_Rotation_Synopsis

This script will rotate a single prim quite nicely:

default
{
state_entry()
{
llTargetOmega(<0,0,1>,0.1,PI);
}

}

Function: llTargetOmega( vector axis, float spinrate, float gain );

 133 Function ID 0 Forced Delay 10 Energy

Rotates the object/prim around axis at a rate of `spinrate * llVecMag(axis)` in radians per second with strength gain.

 • vector axis – arbitrary axis to rotate the object around • float spinrate – rate of rotation in radians per second • float gain – also modulates the final spinrate and disables the rotation behavior if zero

## Specification

### Physics

• If the object is not physical or the script is attached to a child prim, then the effect is entirely client side. Only a script within the object itself can detect this by reading the PRIM_OMEGA parameters.
• If the object is physical and the script is attached to the root prim, then the physical representation is updated regularly. The rotation experienced by the user can be detected or queried by script.

• If the script is attached to the root prim, the entire object rotates around the region axis.
• If the object is attached then it rotates around the attachment axis.
• If the script is attached to a child prim, the prim rotates around the local axis.
• A child prim can rotate around its own axis while the entire object rotates around another axis.

## Caveats

• If the object is not physical then the rotation is only a client side effect and it will collide as non-moving geometry.
• If the function does not appear to be working, make sure that that Advanced > Network > Velocity Interpolate Objects (viewer 1.x) or Develop > Network > Velocity Interpolate Objects (viewer 2.x) is enabled.

##### Share on other sites

• 0

This might be better discussed in the Scripting forum, but, briefly, there's a distinction between rotating something -- that is, moving if from one rotation to another, like a door moving through 90 degrees and back -- and making it spin.

If you want to make it spin (that is, rotate continuously) you almost certainly need llTargetOmega  or maybe llSetKeyFramedMotion.

llTargetOmega is probably the most widely used (and it's what people usually mean when they talk about "a rotation script").   In non-physics objects, the rotation is a client-side effect; that is, the object is spinning because your computer is drawing it that way.   As far as the sim is concerned, it's static.   So it wouldn't, on its own, be suitable for a rotating door, but  would be excellent for a cieling fan.

##### Share on other sites

• 0

Thank you! But I want to set a object with 3 separate objects linked together.Do you know how to set the linked three objects to rotate separately?Thanks!

##### Share on other sites

• 0

Thank you! But I want to set a object with 3 separate objects linked together.Do you know how to set the linked three objects to rotate separately?Thanks!

##### Share on other sites

• 0

The 2nd link had a table that offers there options for this type of rotation > llTargetOmega† ll[GS]PP: PRIM_OMEGA - spin linkset around prim's location - You;ll need to read that to do this.

http://wiki.secondlife.com/wiki/PRIM_OMEGA

##### Share on other sites

• 0

What is this "ll[GS]PPRIM_OMEGA"?Could you please explain it to me more clearly?

##### Share on other sites

• 0

I see now! Thank you very much!

##### Share on other sites

• 0

I used this scripts in the child prims only.then the child prims can rotate separately.But after I used this scripts in the root prim,the three objects rotate together and at the same time the child prims rotate by themself.I want to set the root prim to rotate separately too.How can I do?

##### Share on other sites

• 0

Yes. If you call llTargetOmega in a child prim, or -- and this would be better, llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,2,PRIM_OMEGA,<1.0,0.0,0.0>,1.0,0.1,PRIM_LINK_TARGET,3,PRIM_OMEGA..... ]); you can make the prims turn separately. Calling llTargetOmega or PRIM_OMEGA in the root prim causes the whole linkset to turn.

##### Share on other sites

• 0

You can't rotate the root prim without making the other prims rotate too. It's just the way SL works. So you will have to change the linking, or possibly add a new (invisible) root prim, which remains static) to achieve the result you want.