Jump to content

rotating a 3 sided prism on click


Awfully Artful
 Share

You are about to reply to a thread that has been inactive for 2853 days.

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

Recommended Posts

I have a mesh prism HUD with 3 sides, each side has a button, I want it to change the rotation of the entire linked object to show a new side/face when the button is clicked. Tried numerous scripts but can't seem to get this to work right. Admittedly I have no scripting knowledge, but thought this would be pretty easy.

Link to comment
Share on other sites

Assuming that the Z axis of the root prim of your HUD is vertical, all you need to do is rotate 120 degrees  (2*PI/3 radians) around Z with each click.  If you rotate the root prim, everything else will follow.  Therefore, the script in your root prim should have a touch_start event that includes

llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION,llEuler2Rot(<0.0,0.0,2 * PI / 3>)*llGetLocalRot()]);

Just be sure that you've made your HUD correctly so that in its ZERO_ROTATION position, you are looking in the same direction as the HUD's +X axis (that is, if your HUD were a cube, you'd be looking at face 4).

 

Link to comment
Share on other sites

Aha.  Well, at least that's easy to fix, assuming that you made the prism.  If you can't just rebuild it the proper way around, you can still fake it by setting your starting rotation in the state_entry event. It's a little clumsier, but still doable.  Suppose you had designed the prism with its first flat face looking west instead of east, for example.  That is, you're looking down the prism's -X axis instead of its +X axis.  In that case, you'd want to start with the prism rotated exactly 180 degrees around Z:

llSetRot(llEuler2Rot(<0.0,0.0,PI>)*llGetLocalRot());

Once you've set that as the starting rotation, in state_entry, all rotations after that will be in 120 degree steps from that rotation.  It's not as good as doing it right in the first place, but hardly a disaster.

You probably ought to read http://wiki.secondlife.com/wiki/Rotation  and http://wiki.secondlife.com/wiki/Creating_HUDs

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2853 days.

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...