Sick Venom Posted October 1, 2016 Share Posted October 1, 2016 Hello, basically I am making an animated tail, in which I want it to wag. With my current animation script, it plays it in the steps 1 2 3 1 2 3, but I need 1 2 3 2 1, and a repeat on that. It looks glitchy going from 3 back to 1. How would I create a script that would make it loop as such? float animation_speed = 0.5; integer total_prims; integer link_counter; default { state_entry() { total_prims = llGetNumberOfPrims(); llSetTimerEvent(animation_speed ); } timer() { link_counter++; llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); llSetLinkAlpha( link_counter,1.0, ALL_SIDES); if( link_counter == total_prims) { link_counter = 0; } } }This is the script Im currently using. I did also use :list ORDER = [ "object1", "object2", "object3", "object2" ]; list frames; integer current_frame = 0; list ListLinked(list Needles) { integer Prims = llGetNumberOfPrims()+1; while(--Prims) { integer Ptr = llListFindList(Needles,[llGetLinkName(Prims)]); if(~Ptr) Needles = llListReplaceList(Needles,[Prims],Ptr,Ptr); } return Needles; } SetFrame( integer frame ) { llSetLinkAlpha( LINK_SET, 0.0, ALL_SIDES); llSetLinkAlpha( frame, 1.0, ALL_SIDES); } default { state_entry() { frames = ListLinked( ORDER ); llSetTimerEvent ( 1.0 ); } timer() { if (current_frame >= llGetListLength(frames)) current_frame = 0; SetFrame(llList2Integer(frames, current_frame)); ++current_frame; } }However when I use this one, and try to make it loop from 3 back to 2, it disappears for a second entirely and still doesnt do what I want. Any help is appreciated. Link to comment Share on other sites More sharing options...
Qie Niangao Posted October 1, 2016 Share Posted October 1, 2016 Before we get to the scripts, a couple of things about efficiency. First, if this is a tail to be worn (as opposed to part of a free-rezzed object), then this whole paradigm of object animation will be completely obsolete once Project Bento goes live, which is expected Real Soon Now. Second, if still using object animation, there's a significant rendering advantage to using alpha masked textures instead of swapping the alpha level between 0.0 and 1.0, which is rendered as alpha blending. You may be working with textures that only look good with alpha blending, though, so the only benefit would be at the fully-transparent state which might not be worth actually swapping textures. Now, the scripts. The first one might be rescued by replacing the simple autoincrement ("++") by instead adding a value that changes from +1 to -1 when the counter reaches the max of the range and then back to +1 when the counter is back down to 0. The second script could be rescued by realizing that there's only one prim named "object2", so once ListLinked() has replaced the first occurrence of "object2" in the list, it won't get another prim with that name to replace the other "object2" in the list. So you could modify it to instead keep trying to llListReplaceList() until it can't find a match. Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 1, 2016 Share Posted October 1, 2016 I haven't tested this in world, but it looks right off the top of my head. float animation_speed = 0.5;integer total_prims;integer link_counter;integer direction = FALSE;default{ state_entry() { total_prims = llGetNumberOfPrims(); llSetTimerEvent(animation_speed ); } timer() { llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); llSetLinkAlpha( link_counter,1.0, ALL_SIDES); if(( link_counter == total_prims) || (link_counter == 0)) { direction = !direction; } if (direction) { link_counter++; } else { link_counter--; } }} Link to comment Share on other sites More sharing options...
Sick Venom Posted October 2, 2016 Author Share Posted October 2, 2016 Yeah I understand on that, its just something I wanted to learn, personal project for now, and I was curious how to get it to work. I am excited for bento to make these things easier. I will see what I can do, thank you for the response! Link to comment Share on other sites More sharing options...
Sick Venom Posted October 2, 2016 Author Share Posted October 2, 2016 This one does loop it correctly, but it still disappears fully for some reason after it does the full loop. 32123poof32123poof, but its getting there, thank you! Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 2, 2016 Share Posted October 2, 2016 Well, then, just offset the loop by one. 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