SwireD Posted November 10, 2019 Share Posted November 10, 2019 Hello! Trying to create a door script with a menu to open in three stages. open, half open and closed. How to do it better? What is responsible for the rotation of the object in this case? This is not for the home but photographic backgrounds. Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 10, 2019 Share Posted November 10, 2019 (edited) It depends on how your door is constructed, of course. Consult the sticky thread at the top of this form about how to write door scripts to see what your options are. Once you have that figured out, then it's just a matter of making the door do two 45 degree rotations, reverse, and do another two 45 degree rotations. Over and over again. If you start with @Innula Zenovka's simple script, for example, you can split her 90 degree rotation into two and get integer intSwing =45; rotation rotSwing; vector vOffset; integer iTouch = 1; //Start with the door fully open ( = 1 ) or fully closed ( = -1 ) default{ state_entry() { rotSwing = llEuler2Rot(<0.0,0.0,(float)intSwing>*DEG_TO_RAD); //45 degrees on the z axis vector size = llGetScale(); vOffset = <(size.x*-0.5),(size.y*-0.5),0.0>;//open away from someone standing in front of face 2 -- that is, in front of the prim -- hinged on the left. } touch_start(integer total_number) { if ( iTouch == 1 || iTouch == -1) // Reverse direction { rotSwing.s *=-1; iTouch = -iTouch; } list l = llGetPrimitiveParams([PRIM_POS_LOCAL,PRIM_ROT_LOCAL]); vector v = llList2Vector(l,0); rotation r = llList2Rot(l,1); llSetPrimitiveParams([PRIM_POS_LOCAL,v+(vOffset-vOffset * rotSwing)*r,PRIM_ROT_LOCAL,rotSwing*r]); ++iTouch; // Prepare for the next step } } If your door is cut or rotates around different axes or has other geometric constraints, you'll start with a different basic script. The approach is the same, though. Think of it as simply rotating the door twice, reversing, and doing it again. Edited November 10, 2019 by Rolig Loon Cleaner wording 1 Link to comment Share on other sites More sharing options...
SwireD Posted November 11, 2019 Author Share Posted November 11, 2019 18 hours ago, Rolig Loon said: It depends on how your door is constructed, of course. Consult the sticky thread at the top of this form about how to write door scripts to see what your options are. Once you have that figured out, then it's just a matter of making the door do two 45 degree rotations, reverse, and do another two 45 degree rotations. Over and over again. If you start with @Innula Zenovka's simple script, for example, you can split her 90 degree rotation into two and get integer intSwing =45; rotation rotSwing; vector vOffset; integer iTouch = 1; //Start with the door fully open ( = 1 ) or fully closed ( = -1 ) default{ state_entry() { rotSwing = llEuler2Rot(<0.0,0.0,(float)intSwing>*DEG_TO_RAD); //45 degrees on the z axis vector size = llGetScale(); vOffset = <(size.x*-0.5),(size.y*-0.5),0.0>;//open away from someone standing in front of face 2 -- that is, in front of the prim -- hinged on the left. } touch_start(integer total_number) { if ( iTouch == 1 || iTouch == -1) // Reverse direction { rotSwing.s *=-1; iTouch = -iTouch; } list l = llGetPrimitiveParams([PRIM_POS_LOCAL,PRIM_ROT_LOCAL]); vector v = llList2Vector(l,0); rotation r = llList2Rot(l,1); llSetPrimitiveParams([PRIM_POS_LOCAL,v+(vOffset-vOffset * rotSwing)*r,PRIM_ROT_LOCAL,rotSwing*r]); ++iTouch; // Prepare for the next step } } If your door is cut or rotates around different axes or has other geometric constraints, you'll start with a different basic script. The approach is the same, though. Think of it as simply rotating the door twice, reversing, and doing it again. Thank you very much! It works absolutely perfectly! Link to comment Share on other sites More sharing options...
Recommended Posts
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