Jump to content

Push direction issue....


Darkraven Danick
 Share

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

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

Recommended Posts

hi there~

hmm I am working on a script that  apply a push to and object,  from  position_A  towards position_B.

 

I know that I can calculate the force via a   llRotBetween(POSA, POSB)   

but I kinda had a hard time trying to figure out the correct equation that works.

 

anyone who had build something similar before? please give me some hint, thanks

Link to comment
Share on other sites

the object that apply the push is an attachment whearing on my own avatar.

and it's suppose to bring a push to any physical object

but I tried both of the following codes, non of them works.......I wonder what's wrong with the code >.<

 

 

vector  force = (posA - posB) * llPow(llVecDist(llGetPos(),posB),3); llPushObject(uuid,force*1000, force*1000,TRUE);

 

 

vector  force = llVecNorm( posB - posA) ; llPushObject(uuid,force*1000, force*1000,TRUE);

 

 PS: I can't say it's totally not working, but only when it's rezzed in-world, and it's puling objects like a whirlpool, rather than sucking objects inside....

 

Link to comment
Share on other sites

eeek sorry for bugging once again, but...

when I use a llSensorRepeat  and a loop in the sensor, trying to apply push to all target it senses, but the codes doesn't work well, in fact it always only apply push to the nearest target, and ignoring the otheres. is there any away to make it serve a muilt-target sense and push in parallel? thanks

Link to comment
Share on other sites

A sensor event works the same way that a touch* event or a collision* event does.  You deal with multiple detected objects or avatars by looping through num ....

sensor(integer num){     integer i;     for(i=0,i<num;++i)     {          llOwnerSay("Detected av #" + (string) i + " is named " + llDetectedName(i));          //Shove him/her     }}

 The detected avatars in a sensor sweep are listed in increasing order of distance from the sensor.

Link to comment
Share on other sites

I hate to say, but.... I AM doing it exactly the same way, but it doesn't seems like working......... >.>

I don't understand what's going on ..............

 

 

sensor(integer d_num){    Loop:  i  from 0 to d_num     {           Key    = llDetectedKey(i);           *........code omitted ...... *          llPushObject(Key,force,<0,0,0>,FALSE);             }      }

 

Link to comment
Share on other sites

If that is literally your code, then it won't work.  Loop: i from 0 to d_num is not LSL syntax. The example I posted uses a for loop, coded in correct LSL syntax.  You could use a while loop, or a do while if you want, but you still have to use LSL syntax.  Study the LSL wiki.

BTW, the force vector in your script is calculated from the position vectors of your object and the detected av.  I assume that you are recalculating that force for each av in the section where you have " ..... code omitted ...." .

Link to comment
Share on other sites

it is a POSEUDO CODE..... =w=

if you think I don't even know a for loop or while / do while loop and need people to explain to me, you are humilating my IQ...

 

and the code in LSL function alread work, but only on a single avatar. I just need it to work on every avatar it detected....\

and the force parameter is exactly like what's mentioned in the previous code, I just omit them cause I don't want to repeat it again and again

Link to comment
Share on other sites

Hehehehe.. Sorry.  I wasn't trying to disrespect you in any way.  It's hard to know how much an OP knows.  Asynchronous communication is a pain.  

At the moment, I don't know what to suggest, but that's mostly because I'm way too tired.  I assume that you really do recalculate those force vectors in the loop for each detected av.

Link to comment
Share on other sites

they do should change due to the index change, i.e. something like:

 

posA = llDetectedPos(i);

keyA = llDetectedKey(i);

Force calculated by the pos between A and B

then apply push on keyA with Force.........

 

 

however, so far as I see, it apply the push only on 1 avatar each time, and when it push the avatar some distance away, it start to push another avatar nearby.      

 

I do set the llSensorRepeat  as 90 meter pi 

and when I put a llSay to detect the UUID, it do give me correct UUID for all avatars it senses in the loop. the only thing no working correctly in the loop is the push ........=.=

Link to comment
Share on other sites

when you say "each time" I assume you mean each pass through the loop.... that's normal behavior, they don't queue up and push all at once...

if the loop is taking to long, you may want to check that unlisted code to see if there are any built in delays that are holding you up, and (re)move them from the push loop. also be aware of energy use by the push function, which can be heavy while serially pushing a large number of avatars, as you may end up with diminishing returns if there aren't any delays

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4685 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...