Script for Climbing a Rope
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
12-20-2007 08:16
Hi, I posted previously in the Animation forum and have a pretty good idea of what I need to do, but the execution of it is confusing me.
I need to have a person click on a rope, and then climb up the rope to the top of a mountain. I've created a climbing animation, and I also have a poseball. The problem is, with the poseball, the avatar returns to their original position once you click "Stand Up" and I want the avatar to remain at the top of the mountain once they've climbed.
It was recommended that I write a script that will move the poseball up while the animation is occuring. (And I guess move the avatar with it). Does this sound like it would work? And, could someone recommend a script that would easily move the poseball?
thank you so much, SB
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
12-20-2007 12:40
Yes, this sounds like it would work. I imagine a climbing animation that is sort of like a mime. It doesn't really move upwards. Then, in the pose ball, there is a script something like //Hit quote to see this formatted
vector dest = <put the destination here> vector start; default { state_entry() { start = llGetPos(); // this should really be done when someone sits on the pose ball llSetTimerEvent(1.0);// and turned off when he stands up again. } timer() { if ( llVecDist( llGetPos(), dest) < 0.5 ) { llSetPos( dest ); llSetTimerEvent(0); } else { vector move = llVecNorm( (dest - llGetPos()) ); llSetPos( llGetPos() + move ); } }
} [\PHP]
This is just off the top of my head, and probably buggy as hell.
lee
_____________________
So many monkeys, so little Shakespeare.
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
12-21-2007 05:34
Just FYI, you can also move the avatar separate from the poseball, using llSetLinkPrimitiveParams(). This could be handy for not having a poseball at all, just embedding everything in the rope to be climbed. (Hmmm... what happens at the end of the climb, though, when you unsit the avatar? I'm reasonably sure he'll unsit not from llSitTarget but rather from the position to which he's been moved--which is what one would want--but might be worth a test first.)
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-02-2008 12:32
From: Qie Niangao Just FYI, you can also move the avatar separate from the poseball, using llSetLinkPrimitiveParams(). This could be handy for not having a poseball at all, just embedding everything in the rope to be climbed. (Hmmm... what happens at the end of the climb, though, when you unsit the avatar? I'm reasonably sure he'll unsit not from llSitTarget but rather from the position to which he's been moved--which is what one would want--but might be worth a test first.) I would rather do it this way without the poseball, but I wasn't sure if it was possible. Can I use llSetLinkPrimitiveParams() to move an avatar *while* applying a climbing animation? I've got the script below working so when the object is touched, it moves slowly to the target point (top of the mountain). How can I add llSetLinkPrimitiveParams() so this movement occurs to the avatar when they touch the object (rather than the object itself animating?)
vector dest = <34,178,35>; vector start; default { touch_start(integer total_number) { vector position = llGetPos(); llSetTimerEvent(1.0);// and turned off when he stands up again. } timer() { if ( llVecDist( llGetPos(), dest) < 0.5 ) { llSetPos( dest ); llSetTimerEvent(0); } else { vector move = llVecNorm( (dest - llGetPos()) ); llSetPos( llGetPos() + move ); } } }
|
|
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
|
01-02-2008 14:47
Absolutely no script needed!
If anyone keeps walking forward against a "wall (or tube)" that is only a LITTLE more than 91° rotated, he walks UP on it!
A(n invisible) tube automatically keeps him on course!
Make 1 hollow half tube for the lower segment (half to have an entrance to the side) and one full hollow tube above it (full for more accurate climbing down). Link the 2 to a linkset. Add more tubes for a longer rope. Turn them by 2° to 10° degree so you can walk up inside of them. Place a flex prim inside the hollow tubes as a rope, make it a little harder, increase gavity on it and let it react less to wind. If its longer than 10, use huge prims, they can be flex, too. Put a 100% transparent texture on the 2 tube parts.
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
01-02-2008 16:46
Another way to do this without scripting the avatar link move is to offset the *animation* so that it starts at the bottom of the rope, with the *sit target* at the top, then when they unseat they will do so at the top, where the animation ends. This will however limit your climb to 5 meters (the max animation offset in any direction). If you move the avatar link while climbing of course this could be a greater distance (up to the applicable link distance), so it depends on your needs.
To make this method smoother, I'd also suggest a starting with a very short (for quick load) "start" anim or even a pose that offsets them to the bottom of the rope for a moment while the "move" animation has time to load and then starts, being played over the top of the start anim at the same priority.
If you combine a slight horizontal (bacwards) offset for the anim, the animation could include climbing up at the end, to end at a 0,0,0 hip offset, to where they will be unseated clear of the rope and ledge, to minimize the "unseat hop".
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
Climbing the Rope, Part 2
01-16-2008 15:00
Hi there- I've got this working using a poseball and the script posted earlier in this thread (the one that Lee called buggy - thanks!!). My problem now is - when the avatar is moved to the position, the poseball moves with her, and then the poseball is up at the top of the cliff. How do I return the poseball to its original position?
Thanks for all your help!
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-16-2008 15:05
From: Schmoo Babenco How do I return the poseball to its original position? The same way you moved it up to the top, but do it after the avatar unsits/stands up. Only going down you don't have to make little movements inbetween except maybe for the 10m limitation on llSetPos() (which you CAN get around using llSetPrimitiveParams()--if interested search these forums for the name given to a commonly used implementation: "WarpPos"  .
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-16-2008 15:10
Another technique sometimes used is to rez another poseball right after a resident uses the existing one. If you do it this way, you can simply delete the moving poseball once it gets to the top (using llDie()), since there's already another at the bottom for the next person to use. One downside of this is that the prim usage on the rope can grow temporarily (lots if many people use the rope at once, unless you build in some kind of limit).
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-16-2008 15:34
Since I'm a newbie to scripting, I'm not sure which part of the script is doing this - sorry. Can you point me in the right direction? Here is the script that is working currently:
// position to sit on the ball e.g <0.0, 0.0, 0.43> // sit 0.5 meter above the ball vector POSITION=<0.0, 0.0, 0.05>; vector dest=<36, 178, 35>; // hovertext above ball. "" for none. // add '\n ' at the end to move text up i.e. // string HOVERTEXT="Sit Here\n "; string HOVERTEXT="Right click and select 'climb'";
// Pie Menu Sit Text. Will only work for the // main prim but included it anyway. If no text // is entered between "" it won't be used. string SIT_TEXT="Climb";
// hovertext color 'r,g,b' e.g. "255,255,255" (white) string HOVER_RGB="255,255,255";
// LISTEN sets if this ball should listen for voice commands // or not. You only need to enable this for 1 ball if you // link several balls to an object. (to reduce lagg). // Change to TRUE to enable FALSE to disable. integer LISTEN=FALSE;
// What channel to listen for hide/show on. If you want to // listen to normal conversation (hide/show), set channel // to 0 otherwise the command will be /channel hide, show integer CHANNEL=8;
// * * * * * * * STOP MODIFY * * * * * * * *//
set_text() { if (llStringLength(HOVERTEXT)>0) { rgb=llCSV2List(HOVER_RGB); llSetText(HOVERTEXT,<llList2Float(rgb,0)*0.003921568627450980392156862745098,llList2Float(rgb,1)*0.003921568627450980392156862745098,llList2Float(rgb,2)*0.003921568627450980392156862745098>,1.0); } else llSetText("",<0,0,0>,0.0); }
start_listen() { llListenRemove(listener); if (LISTEN==TRUE) listener=llListen(CHANNEL,"","",""); } hide_me() { llSetAlpha(0.0, ALL_SIDES); llSetText("",<0,0,0>,0.0); } show_me() { llSetAlpha(1.0, ALL_SIDES); set_text(); } list rgb; string animation; integer listener; default { state_entry() { if (llStringLength(SIT_TEXT)>0) llSetSitText(SIT_TEXT); llSitTarget(POSITION, ZERO_ROTATION); set_text(); start_listen(); } on_rez(integer r) { start_listen(); } listen(integer channel, string name, key id, string msg) { if (msg=="hide") { hide_me(); llMessageLinked(LINK_SET,0,"hide", NULL_KEY); } else if (msg=="show") { show_me(); llMessageLinked(LINK_SET,0,"show", NULL_KEY); } } changed(integer change) { if (change & CHANGED_LINK) { if (llAvatarOnSitTarget() != NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); llGetPos(); // this should really be done when someone sits on the pose ball llSetTimerEvent(1.0);// and turned off when he stands up again.
} else { integer perm=llGetPermissions(); if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(animation)>0) llStopAnimation(animation); llSetAlpha(1.0, ALL_SIDES); set_text(); animation=""; } } } timer() { if ( llVecDist( llGetPos(), dest) < 0.5 ) { llSetPos( dest ); llSetTimerEvent(0); } else { vector move = llVecNorm( (dest - llGetPos()) ); llSetPos( llGetPos() + move ); } }
run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("climb2"); animation=llGetInventoryName(INVENTORY_ANIMATION,0); llStartAnimation("climb2"); llSetAlpha(0.0, ALL_SIDES); llSetText("",<0,0,0>,0.0); } }
link_message(integer sender_num, integer num, string str, key id) { if (str=="hide") { hide_me(); } else if (str=="show") { show_me(); } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-16-2008 16:57
It would be the bit in the 'timer' event handler. The part that calls llSetPos().
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-16-2008 17:49
Try this: changed(integer change) { if (change & CHANGED_LINK) { vector start_pos; if (llAvatarOnSitTarget() != NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); start_pos = llGetPos(); // this should really be done when someone sits on the pose ball llSetTimerEvent(1.0);// and turned off when he stands up again. } else { integer perm=llGetPermissions(); if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(animation)>0) llStopAnimation(animation); llSetAlpha(1.0, ALL_SIDES); set_text(); animation=""; vector pos = llGetPos(); do { llSetPos(start_pos); } while(start_pos != pos); } } }
It gets the position of the object when they sit on it and when they stand it will move it back to that spot.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-17-2008 06:42
Hi Jesse, thank you for your help! I tried this script and the poseball disappeared after the avatar stood up. I can't find it anywhere!  Any ideas?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-17-2008 07:19
From: Schmoo Babenco Hi Jesse, thank you for your help! Make sure that vector start_pos; is declared up top as a global variable. I tried this script and the poseball disappeared after the avatar stood up. I can't find it anywhere!  Any ideas? It should have gone back to where you originally sat down on it. It tried it last night and it worked fine. If you are still having a problem then I'll go over it again this evening when I get home.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-17-2008 07:26
I'm fairly certain it's my error. I will keep working on it today and see if I can figure out what I did wrong. thank you!
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-17-2008 07:29
Jesse - thanks! I got it working - I added vector start_pos at the top as a variable and all is well.
thanks to everyone for their help!
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-17-2008 07:39
Okay. I spoke too soon. Here's what's happening: the poseball returns to the original position now, but when I try to climb the rope again, the avatar doesn't move upwards the second time around.
so: I right click on the poseball. The poseball + avatar move to the destination. The avatar stands up. The poseball returns to original position. I go back down to do it again, and the avatar doesn't move at all.
I'm going to keep troubleshooting, but any thoughts, Jesse, or anyone else?
I added this to the top:
vector start_pos=<35.365,190.914,24.505>;
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-17-2008 19:22
My fault. OK 1st in troubleshooting, simplify! Stripped out everything that wasn't necessary and came up with this. When I 1st added the llOwnerSay's for the if and else test, they worked 1st time but then nothing happened the second time as you pointed out. So the script was busy doing something, somewhere and wasn't processing the link change. I commented what I did to debug it: vector POSITION = <0.0, 0.0, 0.05 >; vector dest = <80, 25, 621>; vector start_pos=<80, 25, 601>;
default { state_entry() { llSitTarget(POSITION, ZERO_ROTATION); } changed(integer change) { if (change & CHANGED_LINK) { if (llAvatarOnSitTarget() != NULL_KEY) { llSetTimerEvent(0.1); // llOwnerSay("changed if");/////1st Added these to see what was happening } else { vector pos = llGetPos(); // llOwnerSay("changed else");/////1st Added these to see what was happening // llSetTimerEvent(0);/////2nd Tried adding this but it didn't work do { llSetPos(start_pos); // llOwnerSay("working"); } while ( llVecDist(llGetPos(), start_pos) > 0.01 );////5th This fixed it // do { // llSetPos(start_pos); // llOwnerSay("working");////3rd Added this and O SHIT!!!!!!!!!!!!!!!!!!!!!! // I HATE endless loops and can't believe I created one :( // } // while (start_pos.z <= pos.z);////4th Tried this and it STILL didn't work } } }
timer() { if (llVecDist(llGetPos(), dest) < 0.5) { llSetPos(dest); llSetTimerEvent(0); } else { vector move = llVecNorm((dest - llGetPos())); llSetPos(llGetPos() + move); } } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-18-2008 11:16
Hi Jesse, The same thing is happening for me still - it works brilliantly the first time, the poseball returns, and then I attempt to do it again and the avatar doesn't move up - just sits.
Again, I'm thinking I could doing something wrong. I used your stripped down script - my only change was the start_pos and dest numbers at the top.
|
|
Schmoo Babenco
Registered User
Join date: 19 Aug 2007
Posts: 12
|
01-18-2008 11:30
It's working! I tweaked the numbers and it's working perfectly now. Thank you, Jesse, for all your help - I have been working on this for days! I have a lot to learn about scripting, and your comments about how you debugged are helpful.
thanks a bunch! SB
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-18-2008 15:20
From: Schmoo Babenco It's working! I tweaked the numbers and it's working perfectly now. Thank you, Jesse, for all your help - I have been working on this for days! I have a lot to learn about scripting, and your comments about how you debugged are helpful.
thanks a bunch! SB Only way to learn and that is by doing it, you are well on your way. Problems like this one are when you start the transtition over from just tweaking and poking at some freebie scripts over to actually grasping some of the concepts. Hope to see plenty more scripting problems and questions posted here by you.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Karmic Forager
Registered User
Join date: 18 Nov 2006
Posts: 18
|
Same question/Pproblem
01-21-2008 12:56
I have no scripting experience, but have made use of freebie scripts and am picking up a little at a time... My latest endeavor is almost exactly the same! I am trying to script a pose ball that will kneel and then crawl through a door and remain seated . Your up the rope script should work for my "though a crawl door" right? Same principals, just diffent directions. I have no problem with the animation side, but can you post the working offset script for the rest of us to use? Thanks! Karmic
|