Jump to content

NotTooManyItems

Resident
  • Posts

    2
  • Joined

  • Last visited

Posts posted by NotTooManyItems

  1. 8 hours ago, Wulfie Reanimator said:

    The most important thing is to negate the avatar's rotation, if you're trying to reference a position in world-coordinates. Otherwise what you have is a relative offset, which means that it will change with the avatar as it rotates.

    This can be done by "dividing" the rotation by the avatar's rotation. (It's not really division, that's just the symbol we use for it.)

    
    vector target = <0,0,0>;
    vector avatar = llGetPos();
    
    vector direction = target - avatar;
    direction.z = 0;
    direction = llVecNorm(direction);
    
    rotation final = llRotBetween(<1,0,0>, direction) / llGetRot();
    
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, final]);

     

    Thanks! Dividing by llGetRot() did it! And the llSetLinkPrimitiveParamsFast() function made the rotation smoother!

    • Like 1
  2. I've got a compass object worn on my avatar and would like it to always be rotated towards a location in world no matter what direction the avatar who wears it is facing.

    At the moment the object points in the correct direction but only when the avatar is facing North.

    Facing North - https://i.gyazo.com/bbd35b98bd439b2971448a12f1aaeeac.png
    Facing South - https://i.gyazo.com/def55de0ad493b0bd7d28b0a35d1a651.png

    In both images the arrow continues to point in the same way but the avatar is facing a different direction. I need the arrow to change to continue facing <0,0,0> when the avatar rotates.

    Code

    vector vTarget = <0,0,0>;
    vector vPos = llGetPos(); //object position
    float fDistance=llVecDist(<vTarget.x,vTarget.y,0>,<vPos.x,vPos.y,0>); // XY Distance, disregarding height differences.
    llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,0>)) * llRotBetween(<1,0,0>,-llVecNorm(<vTarget.x - vPos.x,vTarget.y - vPos.y,0>)));

    SOLUTION

    vector vTarget = llList2Vector(waypoints, current_waypoint);
    rotation vRot = llGetRot();
    vector vAvatar = llGetPos();
    vector direction = (vTarget - vAvatar) / vRot;
    direction.z = 0;
    direction = llVecNorm(direction);   
    rotation final = llRotBetween(<1,0,0>, -direction);   
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, final]);

     

×
×
  • Create New...