Mollymews Posted November 11, 2020 Share Posted November 11, 2020 i got asked about how to have HUD buttons pop down when they are pressed and pop back up when released to help with visual feedback a way to do this is with touch_start and touch_end. (it also works on non-HUD objects) Example: // script goes in the root prim which acts as a backboard for linked prim buttons // as wrote the buttons are linked / surfaced on Face 4 of the root prim // Face 4 being the default orientation of a (root) HUD prim integer buttonLink; vector buttonPos; default { touch_start(integer total_number) { // check that there is no button currently being actioned if (buttonLink == 0) { // we are good integer link = llDetectedLinkNumber(0); string name = llGetLinkName(link); if (llGetSubString(name, 0, 5) == "button") // are we a button prim ? { // button prim names begin with button. Like // button1, button2, button3, etc // buttonRed, buttonGreen, buttonBlue, etc // save link number and local pos buttonLink = link; buttonPos = llList2Vector(llGetLinkPrimitiveParams(link, [PRIM_POS_LOCAL]), 0); // popdown button by (m) margin float m = 0.005; llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, <buttonPos.x - m, buttonPos.y - m, buttonPos.z - m>]); } } } touch_end(integer total_number) { integer link = llDetectedLinkNumber(0); if (link == buttonLink) { // we are good, this is the same button as in touch_start // action the button // whichever way works for you string name = llGetLinkName(link); if (name == "button1") { // do button1 } else if (name == "button2") { // do button2 } // else if other buttons // after we have completed the button action // popup button and null buttonLink llSetLinkPrimitiveParamsFast(buttonLink, [PRIM_POS_LOCAL, buttonPos]); buttonLink = 0; } } } 1 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