Daniells Brandi Posted June 25, 2012 Share Posted June 25, 2012 I have this script example: // A simple animation override example. // Make the avatar run in mid-air when jumping. key gOwner; // the wearer's key string gLastAnimation; // last llGetAnimation value seen // User functions Initialize(key id) { if (id == NULL_KEY) { // detaching llSetTimerEvent(0.0); // stop the timer } else { // attached, or reset while worn llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); gOwner = id; } } // Event handlers default { state_entry() { // in case the script was reset while already attached if (llGetAttached() != 0) { Initialize(llGetOwner()); } } attach(key id) { Initialize(id); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llSetTimerEvent(0.25); // start polling } } timer() { string newAnimation = llGetAnimation(gOwner); if (gLastAnimation != newAnimation) { // any change? if (newAnimation == "Jumping") { // You can stop the built-in animation if you like, if // it might interfere with your own. Be aware that an // avatar can become stuck, and some llGetAgentInfo results // can be inaccurate, if you stop built-ins indiscriminately. // Always test. // // llStopAnimation("jump"); llStartAnimation("run"); } else if (gLastAnimation == "Jumping") { // just finished jumping // "run" is looped, so we have to stop it when we are done. llStopAnimation("run"); } gLastAnimation = newAnimation; // store away for next time } } } http://wiki.secondlife.com/wiki/LlGetAnimationbut when I use "Soft Landing" or "Landing" it does not work as it should! I have a script AO complete, works all the moves, but the script is very complex and how I wish only that this animation to work, do not really know what to do. thanks Link to comment Share on other sites More sharing options...
Dora Gustafson Posted June 25, 2012 Share Posted June 25, 2012 Daniells Brandi wrote: but when I use "Soft Landing" or "Landing" it does not work as it should! This is a very wide definition that doesn't say much. What happens when you do what? In general it is a good idea to stop all running animations before starting. This snippet does that for the owner: list allAnims = llGetAnimationList( llGetOwner());integer i = llGetListLength( allAnims);while ( i>0 ) llStopAnimation( llList2Key( allAnims, --i)); Link to comment Share on other sites More sharing options...
Daniells Brandi Posted June 25, 2012 Author Share Posted June 25, 2012 Thanks for help Dora I just wanted to run a different animation for these movements: pre jump - my animation1 ("PreJumping" ok) jump - my animation2 ("Jumping" is ok) pos jump - my animation3 (not always work) I am beginner in scripts, when I use this example I put above, all work except when I put "Landing" or "Soft Landing", works sometimes stopped whenever jump function. If I jump on moving forward, it does not work. Link to comment Share on other sites More sharing options...
Daniells Brandi Posted June 25, 2012 Author Share Posted June 25, 2012 this is the script I'm trying to do. key gOwner;string gLastAnimation; Initialize(key id) { if (id == NULL_KEY) { llSetTimerEvent(0.0); } else { llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); gOwner = id; }} // Event handlers default{ state_entry() { if (llGetAttached() != 0) { Initialize(llGetOwner()); } } attach(key id) { Initialize(id); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llSetTimerEvent(0.25); // start polling } } timer() { string newAnimation = llGetAnimation(gOwner); if (gLastAnimation != newAnimation) { // any change? if (newAnimation == "PreJumping") { llStartAnimation("pre"); } else if (gLastAnimation == "PreJumping") { llStopAnimation("pre"); } if (newAnimation == "Jumping") { llStartAnimation("jump"); } else if (gLastAnimation == "Jumping") { llStopAnimation("jump"); } if (newAnimation == "Landing") { llStartAnimation("pos"); } else if (gLastAnimation == "Landing") { llStopAnimation("pos"); } gLastAnimation = newAnimation; // store away for next time } }} Link to comment Share on other sites More sharing options...
Dora Gustafson Posted June 25, 2012 Share Posted June 25, 2012 Your script is working but the logic may need some changesI monitored a jump by entering this line in the timer loop in your script: llOwnerSay("New: "+newAnimation); and got these sequense: New: PreJumpingNew: JumpingNew: LandingNew: Standing Sometimes I had this: New: PreJumpingNew: JumpingNew: WalkingNew: Standing This shows that you can not be sure the jump ends with a landing May I suggest you try something like this for your timer event handler: timer() { string newAnimation = llGetAnimation(gOwner); if (gLastAnimation != newAnimation) { // any change? if (newAnimation == "PreJumping") newplay = "pre"; else if (newAnimation == "Jumping") newplay = "jump"; else newplay = "pos"; llStartAnimation(newplay); llStopAnimation(oldplay); gLastAnimation = newAnimation; // store away for next time oldplay = newplay; } } oldplay and newplay are new global variables Link to comment Share on other sites More sharing options...
Daniells Brandi Posted June 25, 2012 Author Share Posted June 25, 2012 thanks Dora, now is work but.. when attaching an object, it executes the first animation pos-jump. and I forgot to say, would have to have one more run and an animation one stand thank you for your help Link to comment Share on other sites More sharing options...
Daniells Brandi Posted June 26, 2012 Author Share Posted June 26, 2012 Ok Dora, I got a somewhat different, but following your example. thanks for the help (sorry my english) 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