Jump to content

Drop Roap efect like anchor

Lolita Erin

Recommended Posts

I don't think they use particles. All they do is move the anchor down relative to the boat, extending a prim between anchor and boat and possibly scaling the texture accordingly as the anchor descends.

Since SL water is usually at most ~20m deep that's no problem and well within linkset restrictions.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

Is this any help? (I reproduce the script,which I found here, because the old LSL wiki sometimes vanishes for a while):


This script creates a pseudo-realistic rope constraint between two objects. Put this script in two nearby physics objects; they should detect one another and become joined by a particle-based representation of a rope. Making one of the objects non-physical and suspending it in mid-air high enough should cause the other, physical object to swing under it. (In fact, it's much less dangerous this way.) This does not require the llPushObject function to be allowed.


// Pseudo-Realistic Rope Constraint by Comrade Podolsky
// Free for non-commercial use.
// Free for commercial use, but if possible, please notify me of what use you found for it. (Besides tether-ball.) But you don't have to.
// And of course, anyone is free and encouraged to modify this script for more specific applications.
// If you need help adapting this script for anything, feel free to try to contact me in-game, but I am rarely online.

integer lockon = FALSE;
float rope_length = 5.0; // Obviously, the length of the simulated rope. (It will stretch slightly longer than this, though)
float dampening = 0.04; // This dampens a fraction of the object's velocity every 0.1 seconds, if the rope is stretched.
float bouncing = 0.4; // How much the object "bounces" back after stretching the rope to the limit of its length. This applies if the rope is stretched suddenly. 0.4 means it will bounce back with  40% of its original velocity. Setting this to below 0 will make the constraint act more stretchy than ropes normally do. Setting this to above 1 will make it unstable and dangerous.
float constant = 16.0; // The force constant of the rope. This applies when the rope is stretched slowly - in which case, it acts sort of like a spring.
key target;
vector ropecolor;
list rope_effect = [];


    timer() { if ( !lockon ){llWhisper(12345,"TEST123"); } } // Automatically locate "other" objects
    listen(integer chan, string name, key id, string msg)
        if (!lockon)
            lockon = TRUE;
            target = id;
            llSensorRepeat("", target, SCRIPTED, 20.0, PI, 0.1); // This part may get rather resource-consuming. For slower-moving objects, and objects roped to something static, range may be decreased and delay may be increased.
            //Sensor range must be at least twice the length of the rope. Stretching the rope farther will cause it to act like it breaks, but it will restore itself if the objects are moved back together.
            rope_effect = // This is the particle effect representation of the rope. Change the colors, alphas, scales, and textures however you like. I can't say how it will affect the effect if you change anything else.
                PSYS_SRC_PATTERN,           PSYS_SRC_PATTERN_DROP,
                PSYS_SRC_TARGET_KEY,        target,
                PSYS_PART_START_COLOR,      ropecolor,
                PSYS_PART_END_COLOR,        ropecolor,
                PSYS_PART_START_ALPHA,      1.0,
                PSYS_PART_END_ALPHA,        1.0,
                PSYS_PART_START_SCALE,      <0.05,1.0,1.0>,
                PSYS_PART_END_SCALE,        <0.05,1.0,1.0>,
                PSYS_SRC_TEXTURE,           "",
                PSYS_PART_MAX_AGE,          0.5,
                PSYS_SRC_BURST_RATE,        0.001,
                PSYS_SRC_BURST_PART_COUNT,  1
    sensor(integer num_detected)
        vector i_pos = llGetPos();
        vector u_pos = llDetectedPos(0);
        if (llVecMag(u_pos-i_pos)>rope_length)
            llSetForce(constant*llGetMass()*llVecNorm(u_pos-i_pos)*(llVecMag(u_pos-i_pos) - rope_length),FALSE); // This is how an ideal spring would behave under these conditions. Without this statement, the rope would stretch slowly but indefinitely. Ropes do not work that way.
            llApplyImpulse( llGetMass() * llGetVel() * dampening * -1.0 , FALSE ); // This dampens the motion of the object, preventing buildup of excess kinetic energy through oscillation.
            vector wrongway = llVecNorm(i_pos - u_pos); // The direction in which the object should NOT be moving
            float wrongmag = ( llGetVel() - llDetectedVel(0) ) * wrongway; // The velocity with which the object is apparently moving, against the pull of the rope.
            if ( wrongmag > 0.0 ) { llApplyImpulse( llGetMass() * ( ( -1.0 - bouncing ) * ( wrongway * wrongmag ) ) , FALSE ); } // Stop the object from stretching too much farther than rope length.
        else { llSetForce( ZERO_VECTOR, FALSE ); } // If the two objects are closer than rope length, the rope doesn't do anything.
        llSetForce( ZERO_VECTOR, FALSE );
    } // If the other object is nowhere to be seen, this object stops doing stuff.


Edited by Innula Zenovka
  • Like 3
Link to comment
Share on other sites

For effects (physics, mesh deformations) calculated server-side and shipped as object updates to every viewer in sight, there's reason to compromise on realism: I'd prefer to see viewer-side particles approximating the drag curvature as best they can, rather than dynamically deform a rope mesh server-side and try to push all those updates over the net.

I haven't tried the "Pseudo-Realistic Rope Constraint" script in-world yet, but I'm pretty sure I'd update it to replace the sensor with llGetObjectDetails calls. Also, if by chance the target's motion is known in advance, it might be cheaper to pre-compute the corresponding trajectory of the end-of-rope emitter and move it around by KFM rather than simulating the physics at runtime. (Or simulate it once, recording the motion, and play it back with KFM at runtime.)

Edited by Qie Niangao
llGetObjectDetails, not "llGetObjectUpdate", duh.
  • Like 2
Link to comment
Share on other sites

I just played with this, making a pendulum and bapping at it with things. It seems to work pretty well, for an older script.

My only problem was shortening the "rope" without adjusting the, erm, elasticity. My pendulum paddleballed around for a few after a really good bap, and the rope snapped, sending the object off the edge of the world. xD

That's a really cool script tho, thanks for sharing it, Innula!

Link to comment
Share on other sites

12 hours ago, Berksey said:

I just played with this, making a pendulum and bapping at it with things

When I read the OP I dimly remembered coming across it years ago, soon after I started learning to script.   I remember having fun playing with it, bouncing around just as you describe (try making one end a physical poseball and sitting on it!).     I'm glad I took the trouble to look it out because it took, me to a mirror site for the old LSL wili, which has some useful examples that aren't in the main wiki (I asked about this once, and it's apparently an IP rights issue -- the old LSL wiki and the LL one have different licences for their content, which means the LL wiki editors aren't allowed to copy stuff from the LSL wiki without the authors' permission,  which is difficult since so many of them have left in the last 10 years or so).  

Since the main LSL wiki has been offline for a few months, I was very pleased to discover the mirror.


Edited by Innula Zenovka
  • Like 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...