Jump to content

arnellou

Resident
  • Posts

    3
  • Joined

  • Last visited

Everything posted by arnellou

  1. Hello everyone, I have a question about my car door script. The door is not opening properly as it rotates 90 degrees and its pivot point or hinge is in the middle. I tried adjusting the x-axis of the vector open_position variable, but it seems to adjust its position first and then perform the rotation.. Please see the video here. Could someone please suggest a solution to fix the pivot/hinge and other issues? Any advice or tips would be greatly appreciated. Thank you in advance for your help. // config vector close_position = <-0.570, 0.190, 1.865>; rotation close_rotation = <0.0, 0.90, 0.0, -1.0>; vector open_position = <-0.770, 0.190, 1.865>; rotation open_rotation = <0.00, 0.00, 0.00, 0.00>; key close_sound = "876d3492-b8b8-7745-f5ae-dc5176ec6105"; key open_sound = "9a076511-9aa8-f50d-e34c-1396a07a66a9"; key lock_sound = "37e8d62e-ba8a-3faf-49cc-7cb9267686da"; key unlock_sound = "37e8d62e-ba8a-3faf-49cc-7cb9267686da"; key chime_sound = "b2aa9559-4e32-8321-09f8-86572fd5bc00"; float close_volume = 1.0; float open_volume = 1.0; float lock_volume = 0.5; float unlock_volume = 0.5; float chime_volume = 0.5; integer channel = 0; integer auto_close = 0; float movement_time = 1.0; integer preload_sounds = FALSE; integer sit_check = FALSE; list whitelist = [""]; string link_name = ""; vector link_close_position = <0.00000, 0.00000, 0.00000>; rotation link_close_rotation = <0.00000, 0.00000, 0.00000, 0.00000>; vector link_open_position = <0.00000, 0.00000, 0.00000>; rotation link_open_rotation = <0.00000, 0.00000, 0.00000, 0.00000>; // integer close_open; integer handle; integer link; vector link_time_position; rotation link_time_rotation; integer locked; integer sitting; float time; vector time_position; rotation time_rotation; // http://wiki.secondlife.com/wiki/Interpolation/Linear/Vector vector vLin(vector x, vector y, float t){ return x*(1-t) + y*t; } // http://wiki.secondlife.com/wiki/Slerp rotation slerp( rotation a, rotation b, float t ) { return llAxisAngle2Rot( llRot2Axis(b /= a), t * llRot2Angle(b)) * a; } close_or_open() { if(llGetLinkNumber() < 2) return; if(llGetLocalPos() != close_position) { llStopSound(); llResetTime(); while(llGetTime() < movement_time) { time = llGetTime() / movement_time; time_position = vLin(open_position, close_position, time); time_rotation = slerp(open_rotation, close_rotation, time); if(link != 0) { link_time_position = vLin(link_open_position, link_close_position, time); link_time_rotation = slerp(link_open_rotation, link_close_rotation, time); } llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POS_LOCAL, time_position, PRIM_ROT_LOCAL, time_rotation]); if(link != 0) llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, link_time_position, PRIM_ROT_LOCAL, link_time_rotation]); } llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POS_LOCAL, close_position, PRIM_ROT_LOCAL, close_rotation]); if(link != 0) llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, link_close_position, PRIM_ROT_LOCAL, link_close_rotation]); if(close_sound != "") llTriggerSound(close_sound, close_volume); } else { if(open_sound != "") llTriggerSound(open_sound, open_volume); llResetTime(); while(llGetTime() < movement_time) { time = llGetTime() / movement_time; time_position = vLin(close_position, open_position, time); time_rotation = slerp(close_rotation, open_rotation, time); if(link != 0) { link_time_position = vLin(link_close_position, link_open_position, time); link_time_rotation = slerp(link_close_rotation, link_open_rotation, time); } llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POS_LOCAL, time_position, PRIM_ROT_LOCAL, time_rotation]); if(link != 0) llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, link_time_position, PRIM_ROT_LOCAL, link_time_rotation]); } llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POS_LOCAL, open_position, PRIM_ROT_LOCAL, open_rotation]); if(link != 0) llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, link_open_position, PRIM_ROT_LOCAL, link_open_rotation]); if(auto_close != 0) llSetTimerEvent(auto_close); if(chime_sound != "") llLoopSound(chime_sound, chime_volume); } } find_link() { integer prims = llGetNumberOfPrims(); integer index; while(prims--) { string name = llGetLinkName(index); if(name == link_name) link = index; index++; } } default { state_entry() { llSetMemoryLimit(llGetUsedMemory() + 1024); handle = llListen(channel, "", llGetOwner(), ""); find_link(); if(preload_sounds == TRUE) { if(close_sound != "") llPreloadSound(close_sound); if(open_sound != "") llPreloadSound(open_sound); if(lock_sound != "") llPreloadSound(lock_sound); if(unlock_sound != "") llPreloadSound(unlock_sound); if(chime_sound != "") llPreloadSound(chime_sound); } } on_rez(integer start_param) { llResetScript(); } touch_start(integer total_number) { key id = llDetectedKey(0); string name = llGetUsername(id); if(id == llGetOwner()) { close_or_open(); return; } if(locked == FALSE) close_or_open(); else if(locked == TRUE) { integer find = llListFindList(whitelist, [name]); if(find != -1) close_or_open(); } } timer() { llSetTimerEvent(0.0); if(llGetLocalPos() != close_position) close_or_open(); } listen(integer channel, string name, key id, string message) { if(sit_check == TRUE) if(sitting == FALSE) return; message = llToLower(message); if(message == "close") if(llGetLocalPos() != close_position) close_or_open(); if(message == "open") if(llGetLocalPos() != open_position) close_or_open(); if(message == "unlock") { locked = FALSE; llTriggerSound(unlock_sound, unlock_volume); } if(message == "lock") { locked = TRUE; llTriggerSound(lock_sound, lock_volume); } } changed(integer change) { if(change & CHANGED_LINK) { find_link(); key av = llAvatarOnLinkSitTarget(LINK_ROOT); if(av == llGetOwner()) if(av) sitting = TRUE; else sitting = FALSE; } } }
  2. Greetings! I am a new Second Life user and I am interested in creating an object similar to the knife being held in the avatar's right hand. Please see the link below: Animated Knife Link I am curious about the process involved in creating such objects, as well as the recommended software tools to use. Would Avastar or Bento Buddy be helpful in creating an animation like this? Specifically, I am wondering whether the knife is an animesh synced to the bento hand. Thank you kindly.
  3. I'm working on an LSL script to animate an arm for an arm wrestling animation in Second Life. My goal is to make the arm animate to a certain direction when I press the 'W / S' or 'UP ARROW / DOWN ARROW' key. The idea is that there's an integer range where 0 has the starting animation pose, 1 - 10 the arm goes to the right direction, and -1 to -10 the arm goes to the left direction. The script seems to work fine the first time I run it, but when I try to go back and forth, the animation stops playing. Any ideas on what might be causing the animation to stop playing when I go back and forth? Any help would be greatly appreciated! Thanks in advance." vector gPosition = <-0.60, 0.00, -0.5>; vector gRotation = <0.0, 0.0, 0.0>; // in degrees // range integer MID = 0; integer MIN = -10; integer MAX = 10; // for hover text vector COLOR_WHITE = <1.000, 1.000, 1.000>; float OPAQUE = 1.0; updateValue() { llSetText((string)MID, COLOR_WHITE, OPAQUE); } declareGameWinner(string team) { llSay(0, team + " WINS"); MID = 0; llStopAnimation("5"); } // function to trigger animation pose based on int value // all these animation pose have priority 4 set adjustArm() { if(MID == 0) { llStartAnimation("0"); } if(MID == -1 || MID == -2) { llStartAnimation("0"); llStartAnimation("-1"); } if(MID == -3 || MID == -4) { llStartAnimation("-1"); llStartAnimation("-2"); } if(MID == -5 || MID == -6) { llStartAnimation("-2"); llStartAnimation("-3"); } if(MID == -7 || MID == -8) { llStartAnimation("-3"); llStartAnimation("-4"); } if(MID == -9 || MID == -10) { llStartAnimation("-4"); llStartAnimation("-5"); } // postive if(MID == 1 || MID == 2) { llStartAnimation("1"); } if(MID == 3 || MID == 4) { llStartAnimation("2"); } if(MID == 5 || MID == 6) { llStartAnimation("3"); } if(MID == 7 || MID == 8) { llStartAnimation("4"); } if(MID == 9 || MID == 10) { llStartAnimation("5"); } } default { touch(integer num_detected) { MID = 0; updateValue(); llSay(0, "Restart Success!"); } on_rez (integer start_param) { llResetScript(); } state_entry() { llSitTarget (gPosition, llEuler2Rot (gRotation * DEG_TO_RAD)); } // for sit animation changed(integer change) { if (change & CHANGED_LINK) { key av = llAvatarOnSitTarget(); if (av) { llSay(0, av); llRequestPermissions(av, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION); llStartAnimation("0"); }else{ llReleaseControls(); } } } // get avatar permissions for controls and animation run_time_permissions(integer perms) { if(perms && PERMISSION_TRIGGER_ANIMATION && PERMISSION_TAKE_CONTROLS) { llTakeControls( CONTROL_FWD | CONTROL_BACK, TRUE, FALSE ); } } // this is where we control the arm base on the value // the adjustArm function is invoked to trigger the animations pose control(key id, integer level, integer edge) { integer start = level & edge; integer end = ~level & edge; integer held = level & ~edge; integer untouched = ~(level | edge); if (start & CONTROL_FWD){ MID++; adjustArm(); updateValue(); } else if (start & CONTROL_BACK){ MID--; adjustArm(); updateValue(); } } }
×
×
  • Create New...