Jump to content

Animate another avatar?


Karmaveat
 Share

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

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

Recommended Posts

I know this has been asked before, BUT I have an object I can wear..a "yeet kicker" when I wear this object and click the feet of someone else, they projectile into the air, I do an animated "kick" and a "yeet" sound plays. Is it possible to have the same effect with this as a "bumper"? Specifically if someone bumps into me could they effectively "yeet" themselves? There are no permissions needed when I click their feet, I can't figure out how to script well enough to know if this is even possible. Below is the script for the "yeet kicker"

default
{
    attach(key k_avatar)
    {
        if (k_avatar != NULL_KEY)
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
    }
    
    run_time_permissions(integer permessi)
    {
        llTakeControls(CONTROL_LBUTTON, TRUE, TRUE);
    }
    
    control(key idTASTO, integer premuto, integer modifica)
    {
        if (premuto & modifica & CONTROL_LBUTTON)
        llSensor("", NULL_KEY, AGENT, 2, PI);
    }
 
    sensor(integer n)
    {
        float forza = llGetObjectMass(llDetectedKey(0)) * 915000;
        vector direzione = llVecNorm(llDetectedPos(0) - llGetPos()) * forza;
        direzione.z = forza;   
        llStartAnimation("Kick");
        llSleep(0.4);
        llTriggerSound("a6a10ad3-3ff1-4532-0e4c-5f222ba35a92",1.0);
        llTriggerSound("c868ee5f-7f2d-5a43-dff5-55701129ed0c",1.0);

        llPushObject(llDetectedKey(0), direzione, ZERO_VECTOR, FALSE);
    }    
}

Link to comment
Share on other sites

This certainly could be modified to trigger the "yeet" effect from a collision_start event instead of a click-triggered sensor() event, and in fact it would be safer inasmuch as the current script actually "yeets" the nearest avatar within 2 meters, regardless of where you click. It would also be simpler (no permissions, no controls, just a little extra housekeeping to filter the collision_start events for avatars and probably add a little hysteresis).

Note, however, that either way, such a script won't work on land set "no push" because it's effectively a push weapon, however light-hearted its intent. It doesn't actually animate the "yeeted" avatar—animation requires permissions, one way or another—and instead uses the llPushObject call on the last line to do the whole deed. That and other physics operations on other avatars won't work on "no push" land.

(Incidentally, the calculation here doesn't scale the force by distance, which is kind of a big deal since the effect is reduced by distance cubed, so maybe it will need adjustment for use in bumping proximity.)

  • Like 1
Link to comment
Share on other sites

UPDATE 😅

default
{
    collision_start(integer num_detected)
    {
        // Check if any avatar is detected
        integer i;
        for (i = 0; i < num_detected; i++)
        {
            if (llDetectedType(i) & AGENT)
            {
                // Adjust the force as per your requirement
                float force = 1000.0;
                
                // Calculate the direction of the push
                vector direction = llDetectedVel(i) * force;
                direction.z = force;
                
                // Push the colliding avatar
                llPushObject(llDetectedKey(i), direction, ZERO_VECTOR, FALSE);

                // Start animation and trigger sounds
                llStartAnimation("Kick");
                llSleep(0.4);
                llTriggerSound("a6a10ad3-3ff1-4532-0e4c-5f222ba35a92", 1.0);
                llTriggerSound("c868ee5f-7f2d-5a43-dff5-55701129ed0c", 1.0);
            }
        }
    }
}

The script is now effectively "yeeting" and playing the sounds appropriate on collision with another avatar.. BUT, is now no longer animating the "Kick" of the wearer.

Link to comment
Share on other sites

2 hours ago, Karmaveat said:

is now no longer animating the "Kick" of the wearer.

you need the attach event from your first script to request the permission to play the animation before you play it (you can remove the permission to take controls).

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

6 hours ago, Quistess Alpha said:

you need the attach event from your first script to request the permission to play the animation before you play it (you can remove the permission to take controls).

Oh, thank you! I completely overlooked the existence of the animation when I suggested "no permissions" would be needed.

As an attachment, though, it really wouldn't hurt to llTakeControls anyway (doesn't actually matter which controls) just for the trick of continuing to work on no-script land. Not sure how much no-script land allows pushing, though, so maybe there's not much point making sure the script can run if it can't actually do the push.

In fact, it could be a benefit to not run on no-script parcels if that prevents the kicking when the parcel is also no-push. But either way, if the script is running on a no-push parcel, one could avoid the kicking animation by beginning the collision_start() handler with something like

       if (PARCEL_FLAG_RESTRICT_PUSHOBJECT & llGetParcelFlags( llGetPos())) return;

to just bail out without kicking or playing the sounds or anything.

Link to comment
Share on other sites

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

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
 Share

×
×
  • Create New...