Katrina Naglo
Resident-
Posts
8 -
Joined
-
Last visited
Reputation
4 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Follow owner avatar at water surface
Katrina Naglo replied to Katrina Naglo's topic in LSL Scripting
So hit another small road bump... When I had some one test this for me, the object insisted on following me. I need it to follow the person who rezed it by firing it from a container prim. Here is the script i am using currently for the floating object that needs to follow the person who fired/rezzed it from an other object they are holding. default { state_entry() { vector pos = llGetPos(); llSetStatus(STATUS_PHYSICS, TRUE); // Little pause to allow server to make potentially large linked object physical. llSleep(0.1); llMoveToTarget(pos,0.4); // Look for owner within 20 meters in 360 degree arc every 1 seconds. llSensorRepeat("", llGetOwner(), AGENT, 20.0, PI,1.0); } sensor(integer total_number) { // Get position of detected owner vector pos = llDetectedPos(0); // Offset . vector offset = <-1,0, (llWater(pos-llGetPos()) - pos.z)>; // offset = offset*llDetectedRot(0); //Adding this line will orient the follower relative to the owner's position. pos+=offset; llMoveToTarget(pos,0.4); } } Thanks for any advice. -
Follow owner avatar at water surface
Katrina Naglo replied to Katrina Naglo's topic in LSL Scripting
Rolig, thank you, I can happily say that worked as required, thank you so much. -
Follow owner avatar at water surface
Katrina Naglo replied to Katrina Naglo's topic in LSL Scripting
Thank you Rolig. I'll add that in and see how it turns out when i have had some sleep. End of a long nightshift at work and scripting is not going to go well if I try it at this time of day! Much appreciated -
Good morning. I am trying to figure out how to make a script that when placed in an object would make it follow its owner (an avatar) whilst maintaining water surface height. I have a script to make it follow the owner, and another to make the object float on water, but i cant find a way to combine both to make the object follow the owner whilst maintaining surface height, when the terrain blow varies in height. Any suggestions would be appreciated. Thanks
-
Thank you Quistess. I tried that in my objects script and it had some effect, just not the right effect. The object, a meshed cylinder shape, appears to be trying to rotate around its Y axis (as opposed to turning its Y axis towards), then snaps back due to the scripting that is leveling out the object on the water as it is not allowed to spin around its X or Y ( Spinning around its Z is allowed). I imagine I need to alter something in the lines you posted above to make it spin around its Z axis so that its Y axis is pointing at the owner? Here is the complete script.. (Appologies for the mess. It does what it should do apart from the rotatoiing towards the owner so I am reluctant to go into it and try to stream line or tidy it up whilst it is working !!) ******** // Float script for a simple air mattress (or somesuch). // The containing object will float around randomly in a // level plane, regardless of altitude or underlying // terrain. The object will orient itself so that its // positive Z (up) axis points straight up. It will also // spin about its Z axis, but not around the X or Y axes. // Typically, you will want to place the containing // object within some type of enclosure. For example, // when placed inside a hollowed cylinder, this object // will bounce around inside the cylinder's hollow. float startingObjectZ; float startingGroundZ; float mass; vector velocity; vector rot; float interval = 1.0; integer x; integer y; integer z; integer counter = 0; vector pos; vector scale; string animation = "AnimLifeVest"; // name of animation in prim inventory string menu = "grab"; //text of option in Right click menu //global vectors for the position and rotation vector sitPosition = <0.1, -0.1, -0.85>; vector sitRotation = <00.0, 0.0, 90.0>; // Customize these options. // Set the same in the matching "Speaking" TARGET TEMPLATE. integer LISTENER_CHANNEL = 120; string SHARED_SECRET = "target me!"; float RETRY_INTERVAL = 1.0; // delay between broadcast attempts integer retry_count = 15; // give up broadcasting # of tries. // re-broadcasts when object is rezzed, (un)linked, attached or touched level() { rot = llRot2Euler(llGetRot()) * RAD_TO_DEG; z = (rot.z < -0.1 || rot.z > 0.1); y = (rot.y < -0.1 || rot.y > 0.1); if(z || y) { rot.z = 0.0; rot.y = 0.0; rot.x = 270.0; rot *= DEG_TO_RAD; llSetStatus(STATUS_PHYSICS, FALSE); llSetRot(llEuler2Rot(rot)); llSetStatus(STATUS_PHYSICS, TRUE); } } setHoverHeight(float z) { llGroundRepel(0.15, TRUE, 1.0); } default { state_entry() { llOwnerSay("In flight for 3 seconds."); llSleep(3.0); llOwnerSay("Rising to surface"); // Turn off display of collision sprites. // llCollisionSprite("";); // Get starting Z position of float and ground. pos = llGetPos(); scale = llGetScale(); startingObjectZ = pos.z + (scale.z/2.0); startingGroundZ = llGround(ZERO_VECTOR); // Make object physical; Disable grabbing; Make object die if it wanders off. llSetStatus(STATUS_PHYSICS, TRUE); // Lock the float's X and Y axes to (theoretically) keep the float level. llSetStatus(STATUS_ROTATE_X|STATUS_ROTATE_Y, FALSE); // Set initial hover height. setHoverHeight(startingObjectZ - startingGroundZ); // Make sure the float is level, get its mass, and give it a random nudge. level(); mass = llGetMass(); // Sleep 1 second then make call. llSleep(1.0); llOwnerSay("Attempting to communicate"); llRegionSay( LISTENER_CHANNEL, SHARED_SECRET ); // the sit rotation is assigned on the degrees set in the global vector sitRotation*=DEG_TO_RAD; //using a function to set the avatars position on the chair rotation finalRotation = llEuler2Rot(sitRotation); //assigning the sit target function using rotation and position supplied llSitTarget(sitPosition, finalRotation); llSetSitText(llToUpper(menu)); // Start the timer. llSetTimerEvent(interval); } changed(integer change) { if(change & CHANGED_LINK) { key sitter = llAvatarOnSitTarget(); if(sitter != NULL_KEY) llRequestPermissions(sitter , PERMISSION_TRIGGER_ANIMATION); else { if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) llStopAnimation(animation); } // An avatar has sat or unsat; get mass. mass = llGetMass(); } } timer() { if(++counter % 2) { // Periodcally adjust repel height to compensate for uneven ground. float groundChange = llGround(ZERO_VECTOR) - startingGroundZ; setHoverHeight(startingObjectZ - (startingGroundZ + groundChange)); } if(counter == 10) { // Even though it shouldn't be necessary with // X & Y rotations locked, keep float level. level(); counter = 0; //rotate to owner. vector posOwner = llList2Vector(llGetObjectDetails(llGetOwner(),[OBJECT_POS]),0); vector Z = <0,0,1>; vector Y = llVecNorm(posOwner-llGetPos()); vector X = Y%Z; Z = X%Y; llRotLookAt(llAxes2Rot(X,Y,Z),0.5,0.1); } } touch_start(integer total_number) { llOwnerSay("Pulling."); key ownerKey = llGetOwner(); vector ownerPosition = llList2Vector(llGetObjectDetails(ownerKey, [OBJECT_POS]), 0); // if the owner is not in the sim, stop fooling around if (llGetAgentSize(ownerKey) == ZERO_VECTOR) return; // else llSetStatus(STATUS_PHYSICS, TRUE); vector objectPosition = llGetPos(); vector direction = llVecNorm(ownerPosition - objectPosition); llApplyImpulse(direction * llGetMass(), 0); } run_time_permissions(integer perm) { if ( perm & PERMISSION_TRIGGER_ANIMATION ) { llStartAnimation(animation); llStopAnimation("sit"); } } on_rez(integer param) { llResetScript(); } } *********** I did drop the script you posted above in a new prim and it did what it was supposed to do. Which makes me think that something is stopping my floating object do whats needed, or that I need to swap axis or something. Thanks for anything you can do to help me make this work. Kat.
-
Good evening, I have been trying to write lines into a script in the root (only) prim of an object so that upon rezing it rises to the surface and points its Y axis at it's owner. The float to surface (on water) is working fine but, I cant figure out how to make it face its Y axis towards its owner. I have tried using the llRotLookAt but it does nothing that is visible apart from it occasionally rocking around its Y axis. I'm not 100% sure where the rotation instructions should be in the script (if it is even the llRotLookAt ). I tried adding; llRotLookAt( llRotBetween( <0.0,1.0,0.0>, llVecNorm( vPosTarget - llGetPos() ) ), 1.0, 0.4 ); or; vector detected = llDetectedPos( 0 ); vector pos = llGetPos(); llRotLookAt( llRotBetween( <0.0, 1.0, 0.0>, llVecNorm( <detected.x, detected.y, pos.z> - pos ) ), 1.0, 0.4 ); Neither did much, but I think they are correct, for something, maybe just not for this? or maybe i have placed it incorrectly in my existing scripting (exert); float startingObjectZ; float startingGroundZ; float mass; vector velocity; vector rot; float interval = 1.0; integer x; integer y; integer z; integer counter = 0; vector pos; vector scale; level() { rot = llRot2Euler(llGetRot()) * RAD_TO_DEG; z = (rot.z < -0.1 || rot.z > 0.1); y = (rot.y < -0.1 || rot.y > 0.1); if(z || y) { rot.z = 0.0; rot.y = 0.0; rot.x = 270.0; rot *= DEG_TO_RAD; llSetStatus(STATUS_PHYSICS, FALSE); llSetRot(llEuler2Rot(rot)); llSetStatus(STATUS_PHYSICS, TRUE); } } If someone could help me out it would really help me avoid wasting another two evenings of trial and error and frustration of no progress in solving this problem. Thank you.
-
Cant get in on any of my families accounts..