Casdon12 Posted April 20, 2013 Posted April 20, 2013 I just got back into SL resently and was wanting to get back into scripting and wanted to have an object to where if i walk in one direct with it having a certain radius it plays one sound and play a completely different sound in the opposite direction just as if I'm entering and exiting a door.Somone please reply I really want to know how to do this.
Xiija Posted April 20, 2013 Posted April 20, 2013 this is just basic direction based on zero rotation, you can mod it to fit your needs? ...you would probably use a timer instead of a touch event , mebbe check llGetAgentInfo for walking? default{ state_entry() { } touch_start(integer total_number) { vector angle = llRot2Euler(llGetRot()); float z = angle.z; if(z >= - PI_BY_TWO && z <= PI_BY_TWO ) { llOwnerSay(" forward"); llPlaySound("open",1.0); } else { llOwnerSay(" backward"); llPlaySound("close",1.0); } }} eta: oops, dunno why i thought it was for an attatchment
Miranda Umino Posted April 20, 2013 Posted April 20, 2013 I assume you are talking about an object on the ground , not an attachement : If you want the direction of the move of the avatar ( to know if the avatar goes closer or not) You will need the velocity vector of the avatar : you may use llDetectedVel ( if you use a sensor ) or llGetObjectDetails(key_avatar, [OBJECT_VEL]) ( if you don t use it) f you want the direction of the avatar even when he turns on himselfwithout changing his position, use llDetectedRot or llGetObjectDetails(key_avatar, [OBJECT_ROT]) . You will need to divide by the rotation of your prim or your object . ( if you want the direction of the avatar relative to the object or prim) If you want the direction of the avatar of his position ( to know if the avtar has crossed your door or not ) The same with llDetectedPos or llGetObjectDetails(key_avatar, [OBJECT_POS]) . Substract the position of the prim or object Divide eventually by the rotation o the object if you want a relative position
Innula Zenovka Posted April 20, 2013 Posted April 20, 2013 This is how I would do the calculation, assuming you want to know your position relative to a conventional box prim -- that is, if you are facing side 2 of the prim it will say "In front" and if you are facing side 4 it will say "behind". default{ state_entry() { // llSay(0, "Hello, Avatar!"); } touch_start(integer total_number) { vector pos = (llDetectedPos(0)- llGetPos())/llGetRot(); if(pos.x>0){ llOwnerSay("In Front"); } else { llOwnerSay("Behind"); } }} ETA -- more accurately, it says "In Front" or "Behind" according to where you are on the prim's x axis.
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