Jump to content

issue restarting an animation


You are about to reply to a thread that has been inactive for 3307 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

hello, sorry for bother you all but i want to know why my script isnt working. i tryed to restart an animation using llStopAnimation(animation1) llStartAnimation(animation1) and doesnt work, but if i use llStopAnimation(animation1) llStartAnimation(animation2) works fine.. why when i want to restart the SAME animation simply continues playing the animation an never stop it and never start it again? i leave you the code here so you can try.. you only have to place this script and 2 animations to try it

 

/////////// USER SETTINGS ////////////////////

string floattext = "Sit Here";
string sittext = "Pose!";
vector textcolor = <1,1,1>;

vector sittarget = <0,0,1>;
vector sitangle = <0.0,0.0,0.0>;

integer listen_handle;
//////////// BEGIN SCRIPT ////////////////////

rotation sitrotation;

default
{
    on_rez( integer sparam )
    {
        llResetScript();
    }
   
    state_entry()
    {
        listen_handle = llListen(1, "", llGetOwner(), "");
        sitrotation = llEuler2Rot(sitangle * DEG_TO_RAD); // convert the degrees to radians, then convert that vector into a rotation
        llSitTarget(sittarget, sitrotation);
        llSetText(floattext, textcolor, 0.8);
        llSetSitText(sittext);
    }

    changed(integer change)
    {
        if(change & CHANGED_LINK) // If someone has sat on, or "linked," to this prim...
        {
            key avataronsittarget = llAvatarOnSitTarget();
            if( avataronsittarget != NULL_KEY )    //Someone is sitting on the object
            {
                llSetText("", textcolor, 0.8);
                llSetLinkAlpha(LINK_SET,0,ALL_SIDES); // Turn Invisible
                // Before animating, first check if we have permission to do so:
                if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget) {
                    // If we do, we can animate:
                    llStopAnimation("sit");
                    llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
                } else {
                    // If we dont, ask for them:
                    llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
                    // We'll animate in the run_time_permissions event, which is triggered
                    // When the user accepts or declines the permissions request.
                }
            }
            else  //stood up
            {
                llSetText(floattext, textcolor, 0.8);
                llSetLinkAlpha(LINK_SET,1,ALL_SIDES); // Make Visible
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if(perm)
        {
            llStopAnimation("sit");
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        }
    }
   
    listen( integer channel, string name, key id, string message )
    {
        if (message == "restart")
        {
            llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0)); // if you use an 1 instead of a 0 WORKS, why!?!?! and how can i resolve my problem?
        }
           
    }
}

 

 

thanks you all.

Link to post
Share on other sites

I guess you have to wait until the animation is actually stopped before you start again and you can not know when it is stopped.
When couple dances are synchronized some rest animation is played at stop and then the both dances are started at the same time.
This indicates you need an extra animation in between to do it properly.
You could try to insert a llSleep( float wait); between stop and start but you have no way of knowing how long a wait you need and it may vary with lag.


deanimo wrote:

hello, sorry for bother you all but i want to know why my script isnt working. i tryed to restart an animation using llStopAnimation(animation1) llStartAnimation(animation1) and doesnt work

Actually I firmly believe your script is working
What you see is more a result of how the viewer interpret animation stop and start. Your script stops and starts almost at the same time, so the viewer will probably receive both in one package and decide not to stop

Link to post
Share on other sites

i m not sure if that is the problem, if it is work with another animation, it should work stopping and playing the same animation, and if the stop takes a time... the anymation should stop at least i think.. maybe it doesnt start again but should stop.. and i already tryed with large sleeps and doesnt work either.. really i dont know what else to do..

 

thanks for your time.

Link to post
Share on other sites

string anim_name; // added this animation as a global

/////////// USER SETTINGS ////////////////////

string floattext = "Sit Here";
string sittext = "Pose!";
vector textcolor = <1,1,1>;

vector sittarget = <0,0,1>;
vector sitangle = <0.0,0.0,0.0>;

integer listen_handle;
//////////// BEGIN SCRIPT ////////////////////

rotation sitrotation;

default
{
    on_rez( integer sparam )
    {
        llResetScript();
    }
  
    state_entry()
    {
        anim_name = llGetInventoryName(INVENTORY_ANIMATION,0);   // defined the variable anim_name .. in this case the first animation found in inventory
       
        listen_handle = llListen(1, "", llGetOwner(), "");
        sitrotation = llEuler2Rot(sitangle * DEG_TO_RAD); // convert the degrees to radians, then convert that vector into a rotation
        llSitTarget(sittarget, sitrotation);
        llSetText(floattext, textcolor, 0.8);
        llSetSitText(sittext);
    }

    changed(integer change)
    {
        if(change & CHANGED_LINK) // If someone has sat on, or "linked," to this prim...
        {
            key avataronsittarget = llAvatarOnSitTarget();
            if( avataronsittarget != NULL_KEY )    //Someone is sitting on the object
            {
                llSetText("", textcolor, 0.8);
                llSetLinkAlpha(LINK_SET,0,ALL_SIDES); // Turn Invisible
                // Before animating, first check if we have permission to do so:
                if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget) {
                    // If we do, we can animate:
                    llStopAnimation("sit");
                    llStartAnimation(anim_name);
                } else {
                    // If we dont, ask for them:
                    llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
                    // We'll animate in the run_time_permissions event, which is triggered
                    // When the user accepts or declines the permissions request.
                }
            }
            else  //stood up
            {
                llSetText(floattext, textcolor, 0.8);
                llSetLinkAlpha(LINK_SET,1,ALL_SIDES); // Make Visible
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if(perm)
        {
            llStopAnimation("sit");
            llStartAnimation(anim_name);
        }
    }
  
    listen( integer channel, string name, key id, string message )
    {
        if (message == "restart")
        {
            llStopAnimation(anim_name);
            llStartAnimation("sit");
            llSleep(0.1);
            llStopAnimation("sit");
            llStartAnimation(anim_name); // if you use an 1 instead of a 0 WORKS, why!?!?! and how can i resolve my problem?
        }
          
    }
}

Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3307 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...