SelItami Posted March 4, 2011 Share Posted March 4, 2011 I have one of the old follower scripts, but I want to be able to use my follower as an attachment, not as an object I have to rez. I searched archives to see if this was possible, and found one thread where someone mentioned they may be able to do it, but I found nothing further. I also contacted the folks from that thread but never got a reply.Is it possible to have a follower as an attachment, and if so, what do I need to change in the script below?///////////////////////////////////////////////////////////////////////// Open Basic Follower/Facing Script, by Logan Bauer. //// You have permission to do whatever you'd like with //// this script, as long as you promise to use it for good //// and not evil. Stick it in your pet cat! Stick it in your //// pet robot! Stick it where'ever you'd like, mutilate the //// code all you'd like, strip out this header, do as you //// will and... have fun! /////////////////////////////////////////////////////////////////////////// OFFSET is the position of your pet in relation to it's owner's position.// For example, in the default setting below, "vector offset =<-1,0,1>;"// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have// it stay left or right, and 1 means have it stay 1m above it's owner. // So, if you wanted the script to make it follow directly in front of you,// and to the left, then you would change it to "vector offset =<1,1,0>;"vector offset =<-1,0,1>;startup(){ vector pos = llGetPos(); llSetStatus(STATUS_ROTATE_Z,TRUE); llSetStatus(STATUS_PHYSICS, TRUE); key id = llGetOwner(); llSensorRemove(); llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);}default{ state_entry() { startup(); } on_rez(integer start_param) { startup(); } sensor(integer total_number) { vector pos = llDetectedPos(0); llMoveToTarget(pos+offset*llDetectedRot(0),.3); llLookAt(pos, .1 , 1); }} Link to comment Share on other sites More sharing options...
Joshua Philgarlic Posted March 4, 2011 Share Posted March 4, 2011 I don't see the sence of using a follower as an attachment or vice versa. An attachment is allways "following", just because it's attached and so there's no script needed. On the other hand a follower has to be rezzed so he can follow. I really don't understand your question :smileysad: ! Link to comment Share on other sites More sharing options...
Serendipity Undercroft Posted March 4, 2011 Share Posted March 4, 2011 I agree with Joshua, you don't need a follower script. You can just wear your follower and edit it so that it follows a short way behind you. The only caveat would be ensuring you attach it to the right point . I'd suggest the spine. Re-reading your post, it seems as though you want to be able to wear it on any attachment and have a script automatically put it in the right postion. I don't know if it's possible. I do wonder whether something like Puppeteer would work though. Probably not but there's a free version you could use to try. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 4, 2011 Share Posted March 4, 2011 Wearing the object as an attachment means that it will mimic your own large body movements, which will actually make it look less natural than if you let it follow you. As you twist and bend, any attached object stays in a constant place relative to the attachment point. That's fine for something like a shoulder pet that is meant to look physically attached to your body, but not so good for something that is supposed to follow at a distance. Your object will tend to whip around every time you change position. The only big advantage to wearing it is that the object will stay with you as you TP or fly, instead of being abandoned. Link to comment Share on other sites More sharing options...
SelItami Posted March 4, 2011 Author Share Posted March 4, 2011 What I'm wanting it for is a roleplay guard. He's one prim, but as you stated, as a normal attachment he bends and twists around on the attachment point as I move. What I want is for him to be able to stay feet on the ground, a set distance behind my avatar, not bending and twisting all over the place since he's only a one prim cutout. Because of his function, I need him to follow me as I move across sim lines. Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted March 4, 2011 Share Posted March 4, 2011 So, if I understand crrectly, you want a follower - not something that is attached to you. You don't really need to sense you all the time - all you have to do is to do an llGetObjectDetails in certain intervals and use llMoveToTarget or just llSetPos to move to the desired position. You want to add a certain offset - but basically, that's all. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 4, 2011 Share Posted March 4, 2011 I thought maybe you had something like that in mind, which is why I mentioned the limitations on both followers and attachments. If you are always crossing a sim line slowly, you shouldn't have trouble with a follower. It will only become detached if you TP away or if you move fast enough that the follower gets out of range. That's less likely to happen if you are walking than if you fly, so you should be OK with a follower that trundles behind you on the ground. At any rate, it will look much smoother and more realistic than an attachment would. You'll just want to set the following position (the offset) lower than your waist, adjusting it experimentally so that the follower's feet are on the ground. Try something like <-1.0,0.0,-1.5> for a start and see what it looks like. Make the follower phantom, too, so it doesn't get hung up on obstacles.Your existing script should be able to handle it. Link to comment Share on other sites More sharing options...
SelItami Posted March 4, 2011 Author Share Posted March 4, 2011 Okay. Part of the reason I had wanted to have it as an attachment was because of areas where I can't build, since I wouldn't think it would be safe to assume every roleplay sim I go to with the guard would allow everyone to build. Thanks for all of the advice so far. Link to comment Share on other sites More sharing options...
Void Singer Posted March 4, 2011 Share Posted March 4, 2011 possible solution 1: since it's a 1 prim cutout, you chould be able to set it realtive to your height by checking llGetAgentSize, and attaching it to your pelvis (as long as there insn't much swish in your walk)... that may work to keep it relatively behind you and settled to the ground...... it won't be prefect, but that's as close as you are likely to get with an attachment possible solution 2: script it as a vehicle, that you sit on (and it animates you as standing/walking), which will definitely solve the leveling problem, although not the turning problem possible solution 3: script it as a vehicle follower. these have some different limitations than normal physics followers, and may survive in a few places that plain physics followers wont by default (mostly do to take controls) Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted March 4, 2011 Share Posted March 4, 2011 And another option, if it's really just a 'cutout' - use particles! I know I mention this quite often but they really are versatile. Have your attachment calculate the offset at which the guard should appear. Emit one particle with (say) a 1s life. Repeat. Repeating with a slightly longer delay than particle life will make it 'flicker' into position - can be quite spooky and atmostpheric if you get it right. Repeating with a slightly shorter delay leaves a sort of 'mouse trails' animation effect, which can also be very effective. A long-ish particle-life with the follow-source flag set makes it, er, 'follow you, which sounds like exactly what you want. Particles have very low impact on sim performance and are a lot easier/quicker to adjust than attachments. Link to comment Share on other sites More sharing options...
Void Singer Posted March 4, 2011 Share Posted March 4, 2011 but should cutouts walk sideways? particles always face the viewer. Link to comment Share on other sites More sharing options...
Kayaker Magic Posted March 5, 2011 Share Posted March 5, 2011 This isn't what you want either, but I have written attachments that move around the avatar. I have bats and little dragons that fly around the avatar and react (more or less) correctly to surrounding avatars. I can imagine a critter that always positions itself between you and the nearest avatar, and excelent guard/thing! Problem is, motion that is appropriate for a flying critter would not be appropriate for a guard/avatar/person/cutout. When an attached bat is swung around by the rotation of the avatar, it just looks like erattic flying behavior. Then when the avatar stands still the bat returns to predictible flying patterns. Perhaps this trick could be used to just put the feet of the attached guard/cuttout on the ground. The fixed position of an attachment would keep it behind you always. Link to comment Share on other sites More sharing options...
SelItami Posted March 5, 2011 Author Share Posted March 5, 2011 As I am new to trying to script anything that is an attachment, or the like, are there any examples I could look at to learn how to set it relative to my height as Void listed as a possible solution? I do plan on turning physics off on the guard, I don't want people to be able to drag him around. I've never seen a vehicle follower, though I admit I've never really had many vehicles. I'll look around and see if I can find any scripts for that option. Thanks again to everyone that is offering suggestions, I truly appreciate it. Link to comment Share on other sites More sharing options...
Void Singer Posted March 5, 2011 Share Posted March 5, 2011 assuming the prim is aligned normally... attach( key vKeyOwn ){if (vKeyOwn){vector vSizOwn = llGetAgentSize( vKeyOwn );llSetScale( <0.01, vSizOwn.y, vSizOwn.z> ); } } that fragment is about the simplest you can do.... if you use a different axis, or need a bit of an offset you'd need to play around the with values and order. Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted March 5, 2011 Share Posted March 5, 2011 Void Singer wrote: but should cutouts walk sideways? particles always face the viewer. What nationality? /me sings "Walk Like An Egyptian" I'm not saying particles are perfect, just much more versatile than usually considered. Link to comment Share on other sites More sharing options...
Void Singer Posted March 5, 2011 Share Posted March 5, 2011 sorry, that did soud like i was shooting it down instead of pointing out a limitation didn't it =X ::likes the Bangles:: Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted March 5, 2011 Share Posted March 5, 2011 No worries, Void, tone seemed fine to me and I was thinking that if anyone was interested in the idea I ought to point out the drawbacks of particles too. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 5, 2011 Share Posted March 5, 2011 In fact, the simplest thing the OP can do is adjust the line right at the top of the script that says vector offset =<-1,0,1>; Right now, that's set so that the follower is one meter behind the av and one meter above the av's waist. Changing it to <-1.0,0.0,-1.5> (assuming that your feet are 1.5 m below your waist) ought to put the follower on the ground. A little tweaking will get it exactly right. Unless the idea is to make a follower that needs to adapt to different owners' heights, that should do it. Link to comment Share on other sites More sharing options...
SelItami Posted March 7, 2011 Author Share Posted March 7, 2011 Well, I finally got a chance to look at this again, and the follower functioning doesn't seem to matter when I wear it as an attachment, so maybe a few of you were right and it can't really be done. I wasn't sure where Void's snippet might go, so I just tried the offset Rolig suggested. If I try just rezzing it as a follower, when I stop, he starts slowly turning in a circle with movement like the hand of a clock. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 7, 2011 Share Posted March 7, 2011 That's because the follower is physical and the script is allowing rotation on the Z axis. If it bumps into anything (like the ground), it will start spinning. You could set STATUS_ROTATE_Z to FALSE, or you could add a bit of code to force the follower to match your own rotation periodically. Off the top of my head, you might try putting llSetTimerEvent(3.0); in the setup function at the top of the script and then adding a timer event that looks something like this in the body of the script: timer() { if(llGetAgentInfo(llGetOwner()) != AGENT_WALKING) { llSetStatus(STATUS_PHYSICS,FALSE); llSetRot(gAgent_Rot); llSetStatus(STATUS_PHYSICS,TRUE); } } To make this work, you will also have to add a line that says rotation gAgent_Rot; at the very top of your script, so that it's a global variable, and then also add a line that says gAgent_Rot = llDetectedRot(0); in the sensor event. The net effect should be that the script checks every 3 seconds to see if you are walking. If not, it makes the follower temporarily nonphysical and matches its rotation to yours, then makes it physical again. Link to comment Share on other sites More sharing options...
SelItami Posted March 7, 2011 Author Share Posted March 7, 2011 Oh, thank you, that did stop him from spinning, he's just a bit jittery at times now hehe. Do all followers have to have physics enabled? I still have the concern of people dragging him about. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 8, 2011 Share Posted March 8, 2011 We're all a little jittery at times. It's the coffee. There are tradeoffs in any script. You could reduce the jitteriness a bit by putting that llSetRot business in the sensor event, but that would really add a lot of work for the sim's servers to do, and add to overall lag. In the end, you have to ask yourself how much it's worth to you. Yes, followers are usually made physical because that's a reliable way to get smooth motion. Link to comment Share on other sites More sharing options...
SelItami Posted March 8, 2011 Author Share Posted March 8, 2011 Well, I'd like to keep it as low lag as possible, so it can stay as is. For now though, the guard may just remain as a normal attachment as I play with the script options more. Link to comment Share on other sites More sharing options...
Void Singer Posted March 8, 2011 Share Posted March 8, 2011 honestly my snippet could be wrapped in default{ <snippet> } for an attachment that was placed on the pelvis and shafted backwards. as for your rotating problem with the folower... that's probably something wrong with the physics, where it's drifting out of alignme (because it's not balanced) and the next move to target call shifts it out of position.... you could set it to non-physical after it moves, and set it physical before it moves which should correct it, or use either llLookAt, or llRotLookAt to force a directionsal facing (which is what most do) Link to comment Share on other sites More sharing options...
SelItami Posted March 8, 2011 Author Share Posted March 8, 2011 Oh, I thought that might be the place for it, but wasn't sure. The original script I posted has llLookAt in the sensor function, which I was wondering if it was somehow off. llLookAt(pos, .1 , 1); 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