Jump to content

KiondraeLoc

Resident
  • Posts

    31
  • Joined

  • Last visited

Posts posted by KiondraeLoc

  1. This is the script I have in my hud:

    string TargetName = "n";
    default {
        
        state_entry() {
            // run this code when entering the default state
            // displays red "OFF" as floating text above the prim
            llRegionSay(3, "off");
            llSetText("OFF", <1,0,0>, 1.0);
            llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
     llClearCameraParams();
      llSetTimerEvent(0.0);
        }
        touch_start(integer num_detected) {
            // when touched, switch to state named 'on'
            state on;
            llRegionSayTo("n", 3, "on");
        }
         }    
            
          
        
    
     
    state on {
        state_entry() {
           
            llRegionSay( 3, "on");
            // run this code when entering state 'on'
            // displays green "ON" as floating text above the prim
            llSetText("ON", <0,1,0>, 1.0);
                llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
     llSetTimerEvent(0.022);
      llListen(4, "","", "");
      
     
     }
      
    
        touch_start(integer num_detected) {
            // when touched, switch to the default state
            state default;
        
        }
        listen(integer channel, string name, key id, string message)
        {
            if(llGetPos())
            {
               list data = llGetObjectDetails(TargetName, [OBJECT_POS, OBJECT_ROT]);
            vector pos = llList2Vector(data, 0);
            rotation rot = llList2Rot(data, 1);
    
            llSetCameraParams([
                CAMERA_ACTIVE, TRUE,
                CAMERA_FOCUS_LOCKED, TRUE,
                CAMERA_POSITION_LOCKED, TRUE,
    
                CAMERA_FOCUS, pos, 
                CAMERA_POSITION, pos + (<0, -2, 1> * rot)  
            ]);
            }
        }
        
    
    }

    This is the script I have in my RC Flying Drone: 

    
    string TargetName = "n";
    default{
        on_rez(integer r){
            llResetScript();
        }
         state_entry()
        {
            llListen(3, "","", ""); 
        }
        listen(integer channel, string name, key id, string message)
        {
             if (llGetOwner() != llGetOwnerKey(id))
            {return;}
            
            if(message == "on")
            {
                 
              llSetTimerEvent(0.05);
            }
              
            if (message == "off")  
            {
                llSetTimerEvent(0.0);   
            }
            
            }
     timer()
        {
          
      llSetObjectName(TargetName);     
            llRegionSay(4,(string)llGetPos());
        }
    }

    How can I get the camera to track the object and not the bottom left corner of the sim at <0,0,0>? I don't want to use the object uuid, I want to use the name of the object to track on a channel so I don't have to keep changing the uuid of my object every time I rez it.

  2. 3 minutes ago, steph Arnott said:

    Can you decide what you want please as it is confusing.

    I want to replace llOwnerSay("beep"); with a touch function that will let me change the texture right or left based on commands along side the buttons. I just don't know the right command to look up to use here. 

  3. 2 minutes ago, steph Arnott said:

    Yes, use a listen function and event.

    //  Says beep to owner the first time owner says something in main chat
    //  and then stops listening
     
    integer listenHandle;
     
    remove_listen_handle()
    {
        llListenRemove(listenHandle);
    }
     
    default
    {
        state_entry()
        {
    //      Change the channel number to a positive integer 
    //      to listen for '/5 hello' style of chat.
     
    //      target only the owner's chat on channel 0 (PUBLIC_CHANNEL)
            listenHandle = llListen(0, "", llGetOwner(), "");
        }
     
        listen(integer channel, string name, key id, string message)
        {
    //      we filtered to only listen on channel 0
    //      to the owner's chat in the llListen call above
     
            llOwnerSay("beep");
     
    //      stop listening until script is reset
            remove_listen_handle();
        }
     
        on_rez(integer start_param)
        {
            llResetScript();
        }
     
        changed(integer change)
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    }

     

     

    I want to change llOwnerSay("beep"); to a touch function and I'm not sure how to do that. What command will allow this?

  4. 18 hours ago, chibiusa Ling said:

     

     

    You could do something like...

    
    //You would put the uuid key of your textures in here like this
    list textures=[
        "00000000-0000-0000-0000-000000000000",
        "00000000-0000-0000-0000-000000000000",
        "00000000-0000-0000-0000-000000000000"
    ];
    
    integer textureIndex; //How far through the above list of textures we have moved
    
    integer textureLink=1;  //Change to the link number to display the texture
    integer rightButton=2;  //Change to the link number of the right button
    integer leftButton=3;   //Change to the link number of the left button
    
    default{
        state_entry(){
            //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
            textureIndex=0;
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
        }
        
        //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture
    
        touch_start(integer x){
            //Change "right button" and "left button" to the link number of the buttons you are pressing
            if(llDetectedLinkNumber(0)==rightButton){
                //Move down through the textures or "to the right"
                ++textureIndex;
                //Display the texture
                llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
                //Check if we have reached the end of the list and if so go back to the start
                if(textureIndex==llGetListLength(textures))textureIndex=0;
            }else if(llDetectedLinkNumber(0)==leftButton){
                //Move up through the textures or "to the left"
                --textureIndex;
                //Display the texture
                llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
                //Check if we have reached the start of the list go back to the end
                if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
            }
        }
    }

    As I said in the script I used llSetLinkTexture but you can use llSetLinkPrimitiveParamsFast if you have gotten that far in your learning. But this script will work for open sim also as all of the above functions, including llSetLinkPrimitiveParamsFast should you choose to use it, are available for use in open sim.

    The llSetLinkPrimitiveParamsFast way of changing texture would be...

    Instead of : llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);

    Use : llSetLinkPrimitiveParamsFast(textureLink, [PRIM_TEXTURE, ALL_SIDES, llList2String(textures,textureIndex), <1.0,1.0,1.0>, <0.0,0.0,0.0>, 0.0]);

    //You would put the uuid key of your textures in here like this
    list textures;
    
    integer textureIndex; //How far through the above list of textures we have moved
    
    integer textureLink=1;  //Change to the link number to display the texture
    integer rightButton=2;  //Change to the link number of the right button
    integer leftButton=3;   //Change to the link number of the left button
    
    default{
        state_entry(){
            //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
            textureIndex=0;
           llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
        }
        
        //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture
    
        touch_start(integer x){
            //Change "right button" and "left button" to the link number of the buttons you are pressing
            if(llDetectedLinkNumber(0)==rightButton){
                //Move down through the textures or "to the right"
                ++textureIndex;
                //Display the texture
                llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
                //Check if we have reached the end of the list and if so go back to the start
                if(textureIndex==llGetListLength(textures))textureIndex=0;
            }else if(llDetectedLinkNumber(0)==leftButton){
                //Move up through the textures or "to the left"
                --textureIndex;
                //Display the texture
               llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
                //Check if we have reached the start of the list go back to the end
                if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
            }
        }
    }

    I thought maybe adding llGetInventoryNumber(INVENTORY_TEXTURE) in place of textures would allow me to drop textures in the root prim and it would automatically detect them, but that puts me back at step one, trying to figure out how to make it work. What should I change to get it to detect the textures automatically so I don't have to update the list if I add, say 157 textures?

  5. 18 hours ago, chibiusa Ling said:

     

     

    You could do something like...

    
    //You would put the uuid key of your textures in here like this
    list textures=[
        "00000000-0000-0000-0000-000000000000",
        "00000000-0000-0000-0000-000000000000",
        "00000000-0000-0000-0000-000000000000"
    ];
    
    integer textureIndex; //How far through the above list of textures we have moved
    
    integer textureLink=1;  //Change to the link number to display the texture
    integer rightButton=2;  //Change to the link number of the right button
    integer leftButton=3;   //Change to the link number of the left button
    
    default{
        state_entry(){
            //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
            textureIndex=0;
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
        }
        
        //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture
    
        touch_start(integer x){
            //Change "right button" and "left button" to the link number of the buttons you are pressing
            if(llDetectedLinkNumber(0)==rightButton){
                //Move down through the textures or "to the right"
                ++textureIndex;
                //Display the texture
                llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
                //Check if we have reached the end of the list and if so go back to the start
                if(textureIndex==llGetListLength(textures))textureIndex=0;
            }else if(llDetectedLinkNumber(0)==leftButton){
                //Move up through the textures or "to the left"
                --textureIndex;
                //Display the texture
                llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
                //Check if we have reached the start of the list go back to the end
                if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
            }
        }
    }

    As I said in the script I used llSetLinkTexture but you can use llSetLinkPrimitiveParamsFast if you have gotten that far in your learning. But this script will work for open sim also as all of the above functions, including llSetLinkPrimitiveParamsFast should you choose to use it, are available for use in open sim.

    The llSetLinkPrimitiveParamsFast way of changing texture would be...

    Instead of : llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);

    Use : llSetLinkPrimitiveParamsFast(textureLink, [PRIM_TEXTURE, ALL_SIDES, llList2String(textures,textureIndex), <1.0,1.0,1.0>, <0.0,0.0,0.0>, 0.0]);

    This helps me understand how it works better, thank you. 

  6. 11 minutes ago, Rolig Loon said:

    It's fairly straightforward to do it with one script.  As long as the script is in the root of the linkset, you can detect which button was touched with llDetectedLinkNumber and than act on the result.  Unless you really want to reinvent the wheel, you may want to adapt Sendao Goodman's classic slide changer script for your purpose.  At least take a look to see one way to handle the logic.

    The script works and I can modify it in Second Life, I just wish the buttons worked like that in Opensimulator as well. I wonder what functions I should change to make it work in Opensimulator.

  7. I want to make a script containing a next and previous button(s) to scroll trough a large amount of textures. Should I make a main script that uses llSay(); with a listen script in the listener prim or should I do one script that calls on the names of the prims in the linkset? Also what LSL functions would be required to achieve this?

  8. I figured it out, it's because the llLookAt command and others like it are single focused. They can't make the prim do two separate things at once using the same command. It's like trying to look to the left and to the right at the same time.

  9. 53 minutes ago, Rolig Loon said:

    Look in Marketplace or post in the Wanted forum. Or make one yourself. 

    I'm looking for one that make the objects follow without too much lag while traveling in the spaceship and I haven't found any in the Marketplace. The only ones I see are in spaceships that are no modify.

  10. 2 hours ago, ellestones said:

    the hard part is evaluating that the typed input is valid and to make the typed entry as simple as possible for the player. Is faster for example to type #2

    #1: /17 <128.0,128.0,20.0>
    #2: /17 128 128 20

    whether using #1 or #2 we have to check that the input coordinate is in bounds

    a way to do this using example #2

    ...

     

    
    // arena bounding box    
    list arena = [
       <128.0,128.0,20.0>,  // arena origin. z = bottom of arena
       <                      
        50.0,               // x width from origin center
        50.0,               // y width from origin center
        100.0               // z height from origin bottom
       >                    // 50,50,100 = 100x100x100 arena box
    ];
    
    default
    {
        state_entry()
        {
            llListen(17, "", llGetOwner(), "");    
        }
        
        listen (integer channel, string name, key id, string text)
        {
        
            list coord = llParseString2List(text, [" "], []);
            vector v = llList2Vector(arena, 0);
            vector w = llList2Vector(arena, 1);
            
            // when input coordinate is out of bounds default to origin coordinate
            float f = llList2Float(coord, 0);
            if (f >= (v.x - w.x) && f <= (v.x + w.x)) v.x = f;
            f = llList2Float(coord, 1);
            if (f >= (v.y - w.y) && f <= (v.y + w.y)) v.y = f;
            f = llList2Float(coord, 2);
            if (f >= (v.z) && f <= (v.z + w.z)) v.z = f;
    
            llSetRegionPos(v); 
        }
    }

     

    Thanks, this most certainly helps.

  11. 10 hours ago, Berksey said:

    It's easier to keep up with fewer threads. It's still the same topic, as far as I'm concerned. You're trying to get a turret gun to work properly, and making a new thread for a new development seems really only to serve as a way of spreading your desire for help into more hooks with bait, to use a fishing analogy. Technically, that would be considered spam by a great many people, and some might even consider it a bit, well, inconsiderate, to abandon a thread when it goes a day with no replies and make a new one asking for the same thing your last post in the first thread asked for.

    Regardless, it's here, and there's no point arguing the reasons for it. I just thought you'd want to know that a lot of people might tend to help someone less if they do the sort of things people usually only do if they feel their needs are more important than the people giving generously of their time and knowledge being able to keep up with topics and help people in an organized, rather than split-apart manner.

    It's just consideration for people who are helping you for free, is all. Don't worry about thanking me for anything, there probably isn't going to be any need for it.

    Dually noted. I didn't think about it like that and you have a point. I agree with you one hundred percent. I won't do that again in the future. I want you and everyone to know that I do care about the people taking the time to help people like me with problems as such as the turret script and that is why I won't do a double thread again as a sign of respect.

  12. 3 hours ago, Berksey said:

    Making a second thread where your last one left off-

    - probably isn't the best way to go about getting people to keep helping you... Just saying.

    When I saw how long the last thread went without a reply, I gave you the gift of an excuse to post again in it without double-posting. For what it's worth, I'm studying up on rotations myself now, and if I can help you with any of this in any way, I'll come back and post what I find out.

    I know how frustrating it can be. Keep trying, keep studying, and if it's got the experts here hesitating to say anything for the moment, rest assured it's something that actually requires some patience, too.

    I'm just a bit of a protectionist and I wanted to create a second thread for solving this part of the problem. Don't you think it would be good to make it easier for others to find answers with two versions as opposed to one? Thank you and I appreciate all the help.

  13. This is the script in the turret. I added the llGetRot(); function bolded in Orange but the turret goes crazy. What should I add to fix it? The turret is linked to the vehicle as a child prim. It works fine as root, but I need it to function as a child prim on the vehicle. I don't want to use the llLookAt(); function because it will mess up my mouse look fighter craft I'm gonna link the turret to.

    You can see what it does in the Gif below. The blue light is the aiming face of the turret prim.

     

    //menu listener
    integer listener;
    integer sensorChannel;
     
    // sensor 
    list avatarsKeys;
    list avatarsNames;
     
    menu(key user,integer channel,string title,list buttons)
    {
        listener = llListen(channel,"","","");
        llDialog(user,title,buttons,channel);
        //remove listener if there's no activity in menu
        llSetTimerEvent(20.0);
    }
     
    integer randomNumber()
    {
        return (integer)(llFrand(99999.0) * -1);
    }
     
    default
    {
        touch_start(integer total_number)
        {
            //only owner can access the menu
            if (llDetectedKey(0) == llGetOwner())
            {
                llSensor("","",AGENT,55,PI);
            }
        }
        sensor(integer total_number)
        {
            integer i;
            key tempId;
            avatarsKeys = [];
            avatarsNames = [];
            i = 0;
            while ((i < total_number) && (i < 12))
            {
                tempId = llDetectedKey(i);
                avatarsKeys = avatarsKeys + tempId;
                avatarsNames = avatarsNames + llKey2Name(tempId);
                i = i+1;
            }
     
            sensorChannel = randomNumber();
            menu(llGetOwner(),sensorChannel,"Select an avatar...",avatarsNames);
        }
     
        listen(integer channel,string name,key id,string message)
        {
            if (channel == sensorChannel)
            {
                integer pos = llListFindList(avatarsNames,[message]);
      integer index = llListFindList(avatarsNames,[message]);
    integer i;
               if(index != -1)
                for (i = 0; i < 100; ++i)
                {
    key kTarget = llList2Key(avatarsKeys,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
    float fDistance=llVecDist(<vTargetPos.x,vTargetPos.y,0>,<vPos.x,vPos.y,0>);


    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTargetPos.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTargetPos.x - vPos.x,vTargetPos.y - vPos.y,0>))*llGetRot());


    llRezObject("bullet", llGetPos()+<2,0,0>*llGetRot(),<20,0,0>*llGetRot(),llGetRot(),0); 
                }
            }
        }
        timer()
        {
            llListenRemove(listener);
            llSetTimerEvent(0.0);
        }
            
    }

    GIF-180515_023808.gif

  14. 11 minutes ago, Wulfie Reanimator said:

    On state_entry: Use llListen on channel 17

    On listen: Use llSetRegionPos and the message that was heard, typecasted to vector. 

    That's the simplest way to do it, without any fancy effects since you didn't specify. I've bolded the words you should look into or ask  about you're confused, unless you actually want someone else to write the script for you

    I was doing something like this: 

    float message1;
    float message2;
    float message3;
    integer listenHandle = 0;
    string message(string src, string divider)
    {
         integer index = llSubStringIndex( src, divider );
        if(~index)
            return llDeleteSubString( src, index, -1);
        return src;
    }
    string message1(string src, string divider) {
        integer index = llSubStringIndex( src, divider );
        if(~index)
            return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
        return src;
    }

    default
    {

      state_entry() {llListen(17, "","", "");
        }
        
        listen(integer channel, string name, key id, string message)
        {
        if (message(message, " ") == "alt")
                {
                   
                }
              
                    message1 = (float)message1(message, " ");
                  
             
       
                    llSetRegionPos(<message1, 0,0>);
               
                  
                }
            
        }
     

     

    But, I'm not sure because I have very light knowledge of scripting.

  15. How do I code a Jump Drive script that lets me type in any x,y,z coordinates on channel 17 that will teleport my spaceship to the specified location anywhere in the region I want to go?

  16. 11 hours ago, Innula Zenovka said:

    In general when you're making this kind of thing, a great deal is going to depend on where the script is in the linkset (is it in the root prim or the child prim it seeks to move) and on how the child prim's local axes (visible when using the local ruler option in the object editor) are oriented.   If the child prim is a mesh you've uploaded it's very likely to have the axes pointing in unexpected directions, which the script has to compensate for.

    If anyone comes across this thread in future and can't get the solutions mentioned here to work, a screenshot of the prim that's being aimed at the target, showing the local axes, will greatly assist people who try to help.

    Adding a picture is a good idea, thanks Innula Zenovka. Right now the turret is just a single prim. I plan on doing a mesh turret later.

    18 hours ago, Rolig Loon said:

    I am in a hurry to catch a plane, so I can't take time to test, but you ought to be able to do it with

    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTargetPos.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTargetPos.x - vPos.x,vTargetPos.y - vPos.y,0>))*llGetRot());

    In general, changing a reference frame in a problem like this is just a matter of doing the matrix multiplication to apply the rotation of the new reference frame to the existing one.  See http://wiki.secondlife.com/wiki/Rotation

    Using the script below, the turret rotates interchangeably between clockwise and counter clockwise directions when it passes the main North, East, South, and West directions. When the front of the vehicle is pointing Northeast, Southeast, Southwest, or Northwest, the turret fires continuously in one direction, clockwise or counterclockwise. The turret is a child prim on top of the root prim of the vehicle. You can see in the Gif file what its actually doing.

     

    //menu listener
    integer listener;
    integer sensorChannel;
     
    // sensor 
    list avatarsKeys;
    list avatarsNames;
     
    menu(key user,integer channel,string title,list buttons)
    {
        listener = llListen(channel,"","","");
        llDialog(user,title,buttons,channel);
        //remove listener if there's no activity in menu
        llSetTimerEvent(20.0);
    }
     
    integer randomNumber()
    {
        return (integer)(llFrand(99999.0) * -1);
    }
     
    default
    {
        touch_start(integer total_number)
        {
            //only owner can access the menu
            if (llDetectedKey(0) == llGetOwner())
            {
                llSensor("","",AGENT,55,PI);
            }
        }
        sensor(integer total_number)
        {
            integer i;
            key tempId;
            avatarsKeys = [];
            avatarsNames = [];
            i = 0;
            while ((i < total_number) && (i < 12))
            {
                tempId = llDetectedKey(i);
                avatarsKeys = avatarsKeys + tempId;
                avatarsNames = avatarsNames + llKey2Name(tempId);
                i = i+1;
            }
     
            sensorChannel = randomNumber();
            menu(llGetOwner(),sensorChannel,"Select an avatar...",avatarsNames);
        }
     
        listen(integer channel,string name,key id,string message)
        {
            if (channel == sensorChannel)
            {
                integer pos = llListFindList(avatarsNames,[message]);
      integer index = llListFindList(avatarsNames,[message]);
    integer i;
               if(index != -1)
                for (i = 0; i < 100; ++i)
                {
    key kTarget = llList2Key(avatarsKeys,index);
    vector vTargetPos = llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0);
    vector vPos=llGetPos();
    float fDistance=llVecDist(<vTargetPos.x,vTargetPos.y,0>,<vPos.x,vPos.y,0>);


    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTargetPos.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTargetPos.x - vPos.x,vTargetPos.y - vPos.y,0>))*llGetRot());


    llRezObject("bullet", llGetPos()+<2,0,0>*llGetRot(),<20,0,0>*llGetRot(),llGetRot(),0); 
                }
            }
        }
        timer()
        {
            llListenRemove(listener);
            llSetTimerEvent(0.0);
        }
            
    }
       

     

     

    So, what should I do here?

     

    The blue light on the front of the prim, linked as a child prim on the vehicle, is the face that aims at the target firing on the Z axis. I placed the first letter of each main direction to show the direction in which the vehicle is facing when rotating.  

     

     

    GIF-180515_023808[1].gif

  17. 1 hour ago, KiondraeLoc said:

    I replaced the llGetRot(); functions with llGetLocalRot(); in the llRezObject(); function and that fixed the issue. I didn't need to use *llGetRot(); in the llSetRot(); function. I also replaced llSetRot(); with llSetLocalRot();. Thanks for helping me figure that out. Now the turret works like a charm. Again, Thanks!

    It only makes the object rezzing fire at the selected AV though. The turret doesn't look at the avatar so I'm still missing something. When I multiply the vehicles rotation, like what

     

    8 hours ago, Rolig Loon said:

    I am in a hurry to catch a plane, so I can't take time to test, but you ought to be able to do it with

    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTargetPos.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTargetPos.x - vPos.x,vTargetPos.y - vPos.y,0>))*llGetRot());

    In general, changing a reference frame in a problem like this is just a matter of doing the matrix multiplication to apply the rotation of the new reference frame to the existing one.  See http://wiki.secondlife.com/wiki/Rotation

     said, the turret starts firing in random circles instead of firing at the selected avatar. I might be missing some extra math here, but I'm not totally sure. What do you think I'm missing?

  18. 6 hours ago, Rolig Loon said:

    I am in a hurry to catch a plane, so I can't take time to test, but you ought to be able to do it with

    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTargetPos.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTargetPos.x - vPos.x,vTargetPos.y - vPos.y,0>))*llGetRot());

    In general, changing a reference frame in a problem like this is just a matter of doing the matrix multiplication to apply the rotation of the new reference frame to the existing one.  See http://wiki.secondlife.com/wiki/Rotation

    I replaced the llGetRot(); functions with llGetLocalRot(); in the llRezObject(); function and that fixed the issue. I didn't need to use *llGetRot(); in the llSetRot(); function. I also replaced llSetRot(); with llSetLocalRot();. Thanks for helping me figure that out. Now the turret works like a charm. Again, Thanks!

  19. 2 hours ago, Rolig Loon said:

    Multiply by the vehicle's rotation.

    May you specify futher on this please? I'm new to scripting so I'm not sure how to go about muliplying by the vehicle's rotation. 

  20. Well, that works as a single prim turret. In a linkset on a moving vehicle that isn't pointing East, the turret doesn't fire at the avatar. The aim changes around. How do I get it to use the vehicle's front direction as its east instead of the local sim axis?

×
×
  • Create New...