Restless Swords Posted March 21, 2017 Share Posted March 21, 2017 I have an object that will be worn (attached). an example (NOT what I am doing) would be crutches. When worn, can their script slow down the actual SPEED (distance covered) during a walk? not the animation, the actual movement speed. I know an alternative would be to create some sort of vehicle that moved (slowly) but would like to keep this as a worn attachment. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 21, 2017 Share Posted March 21, 2017 (edited) I'd play around with either llApplyImpulse(< -n, 0.0,0.0>,,TRUE) or llSetForce(-< -n, 0.0,0.0>, TRUE) in the control event, using different values for n until you find something appropriate. I made something years ago that does this. I'll try to dig it out tomorrow and see how I did it back then.. Note that you'll need a special animation to get this to work, though, otherwise the user's feet will be sliding about, since walking animations usually assume the default SL forward walking pace of 3.2 metres/second Edited March 21, 2017 by Innula Zenovka 2 Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 21, 2017 Share Posted March 21, 2017 You might try using llMoveToTarget in a control event. Link to comment Share on other sites More sharing options...
AlduousMcBurlington Posted March 21, 2017 Share Posted March 21, 2017 (edited) Maybe something like... float meters_per_second = 3.2; // change this to set max speed of avatar //-------------------------------------------------------------------------------- float step; vector pos; key attacher; default { state_entry() { step = meters_per_second * 0.1; } attach(key attach_id) { if(attach_id != NULL_KEY && llGetAttached() > 0) { pos = llGetPos(); attacher = attach_id; llSetTimerEvent(0.1); } } timer() { vector current_pos = llGetPos(); if( llVecDist(current_pos, pos) > step ) { integer agent_info = llGetAgentInfo(); if( (agent_info & AGENT_WALKING) || (agent_info & AGENT_ALWAYS_RUN) ) { vector direction = current_pos - pos; if(direction.x > step) direction.x = step; else if(direction.x < -step) direction.x = -step; if(direction.y > step) direction.y = step; else if(direction.y < -step) direction.y = -step; if(direction.z > step) direction.z = step; else if(direction.z < -step) direction.z = -step; pos += direction; llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, pos]); } else pos = llGetPos(); } else pos = llGetPos(); } } Keep in mind that this does not account for agents crossing sim/region boundaries, and may cause a jerking motion when they're corrected; it's a decent example albeit written from scratch, so I have no idea about how compile-able it is. Edited March 21, 2017 by AlduousMcBurlington 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 21, 2017 Share Posted March 21, 2017 2 hours ago, AlduousMcBurlington said: llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, pos]); Won't this only work if you are sitting on it, and it is non-physical? 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 21, 2017 Share Posted March 21, 2017 7 hours ago, Innula Zenovka said: I'd play around with either llApplyImpulse(< -n, 0.0,0.0>,,TRUE) or llSetForce(-< -n, 0.0,0.0>, TRUE) in the control event, using different values for n until you find something appropriate. I made something years ago that does this. I'll try to dig it out tomorrow and see how I did it back then.. Note that you'll need a special animation to get this to work, though, otherwise the user's feet will be sliding about, since walking animations usually assume the default SL forward walking pace of 3.2 metres/second I like these approaches, like a "flight feather" but opposite. Link to comment Share on other sites More sharing options...
Restless Swords Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) Alduous, I think your suggestion would move the box/item attached to my avatar only if I was sitting on the box, not if I wear it as an attachment? - and then the agent would never be WALKING, just SITTING? ---- unless there is something I am totally missing Edited March 21, 2017 by Restless Swords Link to comment Share on other sites More sharing options...
Restless Swords Posted March 21, 2017 Author Share Posted March 21, 2017 So far it seems that everyone is in consensus that there is no way to alter the SL default walk speed (3.2 m/s) ? - what a shame, I might have to resort to using the 'sit' vehicle approach and new custom animations, which I really wanted to avoid Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 21, 2017 Share Posted March 21, 2017 3 minutes ago, Restless Swords said: Aldus, I think your suggestion would move the box/item attached to my avatar only if I was sitting on the box, not if I wear it as an attachment? - and then the agent would never be WALKING, just SITTING? ---- unless there is something I am totally missing No, that ought to work in an attachment too. I think you're right that it will not look like walking, though, unless you also trigger an animation whenever you move forward. That would certainly be true if you used this approach in an object that you sit on instead of an attachment. Link to comment Share on other sites More sharing options...
Restless Swords Posted March 21, 2017 Author Share Posted March 21, 2017 8 minutes ago, Rolig Loon said: No, that ought to work in an attachment too. I think you're right that it will not look like walking, though, unless you also trigger an animation whenever you move forward. That would certainly be true if you used this approach in an object that you sit on instead of an attachment. Hmmm, would not the standard SL WALK animation be running? - I can understand it might look funny ('sliding' slightly backwards) since the forward distance would no longer be the normal 3.2 m/s - If I have to create and play my own WALK animation, I am almost back to going with the sit-on-vehicle and doing my own movement and animation Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 21, 2017 Share Posted March 21, 2017 Try it and see. It's easy enough to test in a few minutes. 1 Link to comment Share on other sites More sharing options...
Restless Swords Posted March 21, 2017 Author Share Posted March 21, 2017 Tried it, without success. 1) when the attachment box was LSL moved, it hopped up a couple of meters in the air, above the avatar bounding box 2) no movement of the attachment box had any affect on the avatar Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 21, 2017 Share Posted March 21, 2017 Oh, well. Worth a try. On reflection, that should have been obvious, since any command like llSetPos, SLPPF with PRIM_POS, or llMoveToTarget is going to move the attachment, not the avatar. So, Innula's suggestion is probably the best one. Try llApplyImpulse. Link to comment Share on other sites More sharing options...
AlduousMcBurlington Posted March 21, 2017 Share Posted March 21, 2017 Actually, since the avatar is physical, I would think that replacing llSLPPF with llMoveToTarget(pos, 0.09); should actually work. But this is, again, me talking out of my hat. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 21, 2017 Share Posted March 21, 2017 llMoveToTarget called in an attachment will move the wearer, certainly. A lot of collars use it. It's really a matter of playing round with llApplyImpulse, llSetForce and llMoveToTarget and seeing which works best for the particular use-case. I have a bit of difficulty visualising how best to use llMoveToTarget if you're simply trying to slow the avatar down, though, since you don't actually want to move the avatar anywhere. You want to make it more difficult for her to move forwards, which isn't the same thing. How do I calculate the target, and what happens when I get there? Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 22, 2017 Share Posted March 22, 2017 5 hours ago, Innula Zenovka said: llMoveToTarget called in an attachment will move the wearer, certainly. A lot of collars use it. It's really a matter of playing round with llApplyImpulse, llSetForce and llMoveToTarget and seeing which works best for the particular use-case. I have a bit of difficulty visualising how best to use llMoveToTarget if you're simply trying to slow the avatar down, though, since you don't actually want to move the avatar anywhere. You want to make it more difficult for her to move forwards, which isn't the same thing. How do I calculate the target, and what happens when I get there? I haven't tried this, but the thought in my head when I suggested llMoveToTarget earlier in this thread was that you set a target that is, say, 3.2 m in front of your current position and tell llMoveToTarget to get there in 2.0 seconds instead of 1.0. Then you run a timer that does a llStopMoveToTarget in 1.0 seconds and re-initiate the llMoveToTarget with a new target if the control event is still receiving a signal from your keyboard forward arrow. I think you could leapfrog ahead like that effectively. My hesitancy, on later reflection, was because I had not tried it yet and began doubting whether the attachment would in fact move the avatar. You know much more about collars that I do, Innula, so you've restored my confidence. I have no idea whether that's a sensible use of server resources, of course. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 22, 2017 Share Posted March 22, 2017 It's used in a collar to constrain movement, to force the wearer to a specific spot and stop her moving away from it, or to make her follow the person holding her leash. It's also used in hug/kiss attachments to get the hugger and huggee close enough to each other. I can see how it could be used to affect movement speed but it just seems to me that llApplyImpulse and llSetForce are going to far simpler to use if you want only to slow down (or speed up) the avatar's normal walking pace. You''re not interested in where the avatar wants to get to; after all; you want only to make it more difficult to move in that direction. So you need only to set the second parameter, LOCAL, to TRUE and specify the vector (<-n,0.0,0.0>) and the simulator does all the calculations for you. As a general rule, though, attachments, including HUDS, can use any of the physics movement functions to move the wearer about (avatars are physics-enabled, but not change her rotation (unless RLV is involved. Non-physical movement functions move the attachment, not the avatar. Link to comment Share on other sites More sharing options...
Xiija Posted March 24, 2017 Share Posted March 24, 2017 (edited) in your control event... if(level & CONTROL_FWD) { if(llGetAgentInfo(llGetOwner()) & AGENT_WALKING ) { llApplyImpulse(<-8.0,0,0>,TRUE); } } Negative values greater than -7 or -8 will make you drift a bit mebbe? Edited March 24, 2017 by Xiija edit 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