Hitman Vendetta Posted February 8, 2022 Share Posted February 8, 2022 Hi! I've been working on a script somone put into the public domain, trying to adapt it to my purpose, which is to rez an NPC when it receives a message via a Dataserver call. Broadly, it works fine, but upon rezing, I want the NPC to adaopt the included (static) animation and to face a particular direction. It's this last part that won't work. No matter what value I put in for the Z rotation, the NPC will behave as follows: 1) It tends not to change direction at all for small (Less than about 7 or 8 degrees) increments/decrements of Z 2) Then it will suddenly change direction by an estimated 20 or so degrees. 3) it cannot be made to face any direction in between it's two jumps 4) For some values, it jumps into a wildly different direction. 5) Overall, it seems to be a toss up between only about 4 or 5 directions it will face, and none other, no matter which of the 360 degrees I try. Here's the relevant piece of code I believe. Where you see "185" in this example; that's the value I'm changing, but the results don't change as expected/intended. Clearly I'm doing something wrong here, but can anyone tell me what? if(npc_on == FALSE) { npc = osNpcCreate("", "", npcPos, npc); npc_on = TRUE; llSensor("", "", AGENT | NPC, 96.0, PI); vector xyz_angles = <1.0, 1.0, 185.0>; vector angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation osNpcSetRot(npc, rot_xyzq); osNpcPlayAnimation(npc, "My animation"); } Thank you in advance for your thoughts! Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 8, 2022 Share Posted February 8, 2022 You're going to have to ask someone in the OS community, not here in SL. Those functions are not part of standard LSL, so unless you are very lucky you'll only get educated guesses here. 2 Link to comment Share on other sites More sharing options...
Hitman Vendetta Posted February 9, 2022 Author Share Posted February 9, 2022 Well said Rolig; I hadn't thought that through very well, had I?! However, I can re-phrase the question. How would this be achieved using pure LSL scripting? Thank you again. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted February 9, 2022 Share Posted February 9, 2022 you can't really get an avatar's rotation to work well in LSL, could try RLV's @setrot or rezzing a temporary seat and turning that then un-rezzing it. 1 Link to comment Share on other sites More sharing options...
Hitman Vendetta Posted February 10, 2022 Author Share Posted February 10, 2022 Thank you Quintess! Can I ask you to elaborate a little in a couple of areas? Firstly, when you say rotation doesn't work well in LSL, do you mean the sort of problems I was experiencing (in OpenSim) are more or less the same story in SL too? More importantly, what are 'RLV's? @setrot'? While not understanding that expression and just going with the rest of the sentence for now - it seems an interesting (if slightly messy!) work-around. So your idea would be to create (eg) a box, sit the NPC on that, rotate the box by a known amount found previously by trial and error, to get the NPC to face the correct direction, then to delete the box and have the NPC adopt the pose that was intended all along? It's a creative solution (if I can make it work). Indeed, if I got it to work fast enough, I might be able to pull it all off while the NPC is still rezzing from it's cloud, and no one would be any the wiser Link to comment Share on other sites More sharing options...
Jenna Huntsman Posted February 10, 2022 Share Posted February 10, 2022 2 minutes ago, Hitman Vendetta said: More importantly, what are 'RLV's? @setrot'? http://wiki.secondlife.com/wiki/LSL_Protocol/RestrainedLoveAPI#Movement That is probably the easiest way to set the rotation of a given avatar. Of course, that would depend on the 'NPC' being able to accept RLV commands. LSL doesn't have any functions to manipulate avatar position and rotation directly. You can apply forces and impulses, but you can't take control away from the user entirely (with exception to taking control of their keyboard inputs). Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 10, 2022 Share Posted February 10, 2022 17 minutes ago, Jenna Huntsman said: LSL doesn't have any functions to manipulate avatar position and rotation directly. You can apply forces and impulses, but you can't take control away from the user entirely That's the heart of it, right there. We can use LSL to rotate objects, but we can't rotate avatars. The standard solution is, as Tessa suggested, to set the avatar temporarily on a transparent prim and rotate it. That can be awkward sometimes, so RVL (a system related to LSL but using its own commands) is a better solution if you know how to use it. 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