Darkraven Danick Posted June 24, 2011 Share Posted June 24, 2011 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 More sharing options...
Void Singer Posted June 24, 2011 Share Posted June 24, 2011 llVecNorm( posB - PosA ) * strength if using global coordinates Link to comment Share on other sites More sharing options...
Darkraven Danick Posted June 24, 2011 Author Share Posted June 24, 2011 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 More sharing options...
Void Singer Posted June 24, 2011 Share Posted June 24, 2011 the second vector should be zero... that controls angular momentum, which you don't want for a straight push, and the last value should be 0, or FALSE. 1 Link to comment Share on other sites More sharing options...
Darkraven Danick Posted June 24, 2011 Author Share Posted June 24, 2011 ah, working much better now, thanks! still a bit glitch since it sucks my object in and then push it away, but I'll try to fix that myself. again thanks a lot :3 Link to comment Share on other sites More sharing options...
Darkraven Danick Posted June 26, 2011 Author Share Posted June 26, 2011 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 More sharing options...
Rolig Loon Posted June 26, 2011 Share Posted June 26, 2011 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 More sharing options...
Darkraven Danick Posted June 27, 2011 Author Share Posted June 27, 2011 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 More sharing options...
Rolig Loon Posted June 27, 2011 Share Posted June 27, 2011 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 More sharing options...
Darkraven Danick Posted June 27, 2011 Author Share Posted June 27, 2011 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 More sharing options...
Rolig Loon Posted June 27, 2011 Share Posted June 27, 2011 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 More sharing options...
Darkraven Danick Posted June 27, 2011 Author Share Posted June 27, 2011 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 More sharing options...
Void Singer Posted June 27, 2011 Share Posted June 27, 2011 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 More sharing options...
Darkraven Danick Posted June 27, 2011 Author Share Posted June 27, 2011 hmm yup I am assuming it's the energy issue... but the for loop is just 4 lines, costs 40 EN in each time's loop at most. it shouldn't act that poor.......there might be something I missed behind, I'll go over the whole script and check it again... 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