Jump to content

Shoulder Hover-ers/Followers


Poocaz
 Share

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

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

Recommended Posts

So, I have just started scripting in Second Life and recently have complete my first project which was making a voice controlled rezzer for my ship ( took me a really long time to do that till I found out what a faux rezzer is), so I thought I would try something else, and now that is being a pain so i wondered if I could grab some help from the senior scripters out there.

It's like this: I have 7 cones, physically modded to resemble spikes of a sorts. Now, six of these spikes are arranged in a circular fashion around the center one which is the parent prim when they become linked. Once they are linked it then initiates a follow command in which the (let's call it a pet) pet will then become horrizontal, hover over my right shoulder, and follow me around. That is simple enough.... What has been giving me probz is getting the spiked ends of the cone to face where I am.... Meaning, if I am facing South west I dont want the points of the cones to be facing north, and, I especially dont want it to do what it's been doing all night which is spinning around randomly then settling on a messed up angle. Ultimately this will be a non-held, mouselook controlled gun, but first I need to: Get my pet (7 cones with one in the middle as parent prim) to hover over my right shoulder and have the points facing where I am.

Sadly, I recently thought I had it and promptly overwrit my script I had been using to put in this new one, but of course, the new one failed as well, and the old one was lost, so I have no script to really show my progress, if we could jsut start from scratch that'd be great

Thank you guys in advance ^^,

Poocaz

Link to comment
Share on other sites

Hi, I cannot help much but hopefully this is useful for you at least in helping to identify a potential method.

vector home;integer numAvatarsNearby;vector nearestAvPosition;key ownerKey;vector ownerPosition;// pointTowardOwner()// turn to point toward the ownerpointTowardOwner(){    vector myPos = llGetPos();    float xdiff = myPos.x - ownerPosition.x;    float ydiff = myPos.y - ownerPosition.y;    float angle = llAtan2(xdiff, ydiff) * RAD_TO_DEG;     setHeading(270 - angle);}// float distanceToNearestAv()// returns the distance in meters to the nearest avatarfloat distanceToNearestAv(){    return llVecDist(llGetPos(), nearestAvPosition);}// float distanceToOwner()// returns the distance in meters to the ownerfloat distanceToOwner(){    return llVecDist(llGetPos(), ownerPosition);}// levelOut()// remove the x and y rotation components, so that the object is// level with respect to the groundlevelOut(){    vector myVec = llRot2Euler(llGetRot());    vector newVec = <0, 0, myVec.z>;    rotation newRot = llEuler2Rot(newVec);    llSetRot(newRot);}// initInternal()// do some setup for internal functions// this includes setting various variables to their defaults// clearing text on the object, and turning on// the repeating sensor and timer eventsinitInternal(){	   ownerKey = llGetOwner();	  	   llSensorRepeat("", "", AGENT, 96, PI, .1);	   llSetTimerEvent(.1);	   startListening();}initAll() {    initInternal();}default{    state_entry()    {        initAll();    }    on_rez(integer start_param)    {        initAll();    }    sensor(integer n)    {        numAvatarsNearby = n;        nearestAvPosition = llDetectedPos(0);        integer i;        for (i=0; i<n; i++) {            if (llDetectedKey(i) == ownerKey) {                ownerPosition = llDetectedPos(i);            }        }    }    touch_start(integer n) {    }    collision_start(integer n) {    }    listen(integer channel, string name, key id, string msg) {    }    timer() {    }  }

 

I've had to heavily edit out a lot of irrelevant stuff so hopefully I got rid of everything not relevant and left in all the bits that should be there. 


Good luck!

Link to comment
Share on other sites

I don't quite understand from the description -- what's the central, root, cone doing?  Is it pointing towards you, like all the others, or looking some other way?

My immediate thought is this would be greatly simplified if you had a root prim -- possibly an invisible one -- that looked the way the follower was going, and it was only the child prims turning to look at you.    

I'll try to give this a shot when I get home this evening (UK time).

Link to comment
Share on other sites

i dont know what you know or what you dont know.

so ill just write everything.

 

you must tell the cones to face a direction, so

either you do it with a timer, or llSetLinkPrimitiveParams, or llMessageLinked to send all prims a message to turn.

how you turn?

you need to get your avatar's rotation

 

you can do it with a sensor. and use        llDetectedRot(0);

 

and the cones should use llLookAt

 

 

 

thats the easy way anyway :)

Link to comment
Share on other sites

of course its not a complete solution, but i thats a direction, i leave you to learn the rest yourself.

ive done several followers, from all kinds, with complicated scripts, 

and ill point you to another problem,

 

you must be using, llMoveToTarget, or something like that.

this function call have a 65m limit.

what happens if you fly really fast?!     the pet will just halt and stay, and you will loose it.

 

so take it into account as well.   :)

Link to comment
Share on other sites

Haha lol can't help much? xD

That was great... but copying and pasting doesn't work, there are some errors, and I can't really tackle the task of understanding it all atm, so is there a way to reformat that into a usable script. I don't want people  to do the work for me, I just want a script that does what I need it to do, then I want to look at it, study it, and understand and be able to reproduce it. Starting from scratch is sometimes  a tad more troublesome.

 

So, when I first posted that it was 1:30 in the morning, a school night for meh, and I had just spent the last six hours working on that script... so I wasn't very clear, so let me restate this.

As said, there are seven cylinders that resemble spikes. Spikes as we all know are basically cylinders that show a decrease or increase in diameter as we move along the object. Generally the smallest diameter of any given spike is labeled "the point". So, when I say the point that is the part I am referring to (the tip, sharp part, w/e you wanna call it :P).

So, the points must ALL face wherever my Avatar is looking, WHILE still remaining at this offset from him:

vector offset =<.30,0,.9>;

That offset there is the position near the right shoulder where I would like the object to remain at at all times (once it has caught up with my avatar((assuming I moved)) ).

Currently I have the Seven Spikes arranged like such (see pic below)

Now, atm my character is facing North and here is the script being used:

default
{
    state_entry()
    {
        llOwnerSay("EHAC Systems Online");
        vector pos = llGetPos() + <0,0,0>;                //Get the current position of the object.
        llSetStatus(STATUS_PHYSICS, TRUE);     //Apply realworld physics.
        llSleep(0.1);                                                  //Wait for 0.1 seconds.
        key id = llGetOwner();                  //Get the key for the owner of this object.
        llSensorRepeat("",id,AGENT,20,2*PI,.10); //Track the location of the owner and updates every 0.4 seconds.
    }

    sensor(integer total_number)
    {
        vector pos = llDetectedPos(0);          //Get the location of object 0, (owner).
        vector offset =<.30,0,.9>;                //Variable used to control the offset.
        pos+=offset;                            //Calculating the offset from the detected position.
        llMoveToTarget(pos,.9);                 //Move to new position with 30% motion smoothing.
    }
}

With this script the object will rez then immediately fly over to its position as you see here. So, its all good.... BUT THEN, the moment I move, in any direction, it goes crazy, I mean, it doesn't fly away or all over the place. But rather, it just rotates on what seems to be every axis, not fast mind you, but still at a moderate pace. And once its done its spaz session it doesn't return to it's starting position when it reaches the offset. No no no; it seems to like to face (spikes) to the right of my character. Even if it was facing downwards when it reached the offset, it will snap to that facing right position.

So yeah.... that's it all :P

Snapshot_001.png

Link to comment
Share on other sites

Ok Mari,

I'll try that, but could you answer a few quick q's?

So, the line is as follows, some of the stuff I get, some I don't, could you clarify?

llSetKeyframedMotion([

<0,0,10>,//sets the vector position for the object

which it will be in when it has "caught" up with the avatar.

The default position for the object

 5, //??What is this?

 <0,0,-10>, ////sets the rotation position for the object which it will be in

when it has "caught" up with the avatar. The default rotation for the object

 5], //again with the five?

 [KFM_DATA, // ?

 KFM_TRANSLATION, // ?

 KFM_MODE, // Specifies the playback mode. So, after this should be "KFM_FORWARD"?

(Instead of Ping Pong?)

 KFM_PING_PONG //So I see this is a mode, but what does it do...

all the others are self explanatory

(reverse,forward,loop((is that just forward repeatedly? o.O)) )

but this one is like- well... idk really....

I didn't know ping pong was a playback mode, thought it was a ball >.<

]);

So, is any of that right? :P

Thanks,

P

The full script: llSetKeyframedMotion([<0,0,10>, 5, <0,0,-10>, 5], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_PING_PONG]); 

Link to comment
Share on other sites

Guess you got the from http://wiki.secondlife.com/wiki/LlSetKeyframedMotion - there's also the explanation :-).

The list for the keyframes is a strided list, in it's complete form: [ target_positionA, target_rotationA, timeA, target_positionB, target_rotationB, timeB, ...] . So, the "5" is the time how long it takes to reach the related position/rotation.

In the example you have, no rotations are used. It's defined by: [KFM_DATA, KFM_TRANSLATION] ....KFM_ROTATION is not set, thus the strided keyframe list is only [position,time, position,time,...] 

Actually, for the follower you need only one keyframe - the 'target-one'.

  • What I'd do roughly: use llSetTarget to define the target position and start the llSetKeyframedMotion towards it. 
  • Because you used  llSetTarget, an event (at_target) will fire when the follower arrived at it's goal
  • in this event you can call a sensor to get the next target-position
  • in the sensor-event you'd call again  llSetTarget and   llSetKeyframedMotion with the new goal.
  • the overall speed can be defined with the 'time' value in  llSetKeyframedMotion (shorter time = faster movement)
Link to comment
Share on other sites

Hm alright, well, for the moment can anyone present a usable script, or one that simply requires the values to be filled in? o.O

The spikes must all be, point first, facing wherever my avatar is currently looking. The offset from my av is:  

vector offset =<.30,0,.9>;

 

Link to comment
Share on other sites

  • 2 weeks later...
You are about to reply to a thread that has been inactive for 4557 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...