Jump to content

Rez an object on the ground so it faces towards the Owner?


jak Scribe
 Share

You are about to reply to a thread that has been inactive for 191 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

So, ...

Step 1:  You rez the object, setting it to ZERO_ROTATION on rez  (using llRezAtRoot, that's the rotation parameter)

Step 2: On Rez, you quickly locate the object's owner. One fast way to do that is to ask 

          vector OwnerPos = llList2Vector(llGetObjectDetails( llGetOwner(),[OBJECT_POS]), 0);

Step 3:  Adjust the Z value of OwnerPos to be the same as the Z value of llGetPos() (that is, the object's own position on rez).  This will make the object keep its Z-axis vertical as it rotates.

Step 4: Rotate the rezzed object to face the owner with llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION,llRotBetween( llGetPos(), CorrectedOwnerPos)]);

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

llRotBetween( llGetPos(), CorrectedOwnerPos)

That may work (I've not tried it) but I think you meant llRotBetween(<1,0,0>, CorrectedOwnerPos-llGetPos()); you want to rotate by an angle defined by a line sticking out from the object going in the forward (x?) direction (<1,0,0>), and a line sticking out from the object pointing at the owner (ownerPos-llGetPos()) rather than 2 lines pointing from the region origin to the owner & object.

to look up/down at the owner, I think you could right multiply that by llRotBetween(CorrectedOwnerPos-llGetPos(),OldOwnerPos-llGetPos());

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You're probably right. That's the problem with posing a response off the cuff too close to bedtime, without taking the time to go in world to see if physics agrees with your brain. Your solution does look more plausible.  Still, the magic is in llRotBetween. That's where the OP has to do his own experiments.

  • Like 1
Link to comment
Share on other sites

14 minutes ago, Rolig Loon said:

the magic is in llRotBetween

actually for a better conceptual understanding, I'd recommend going through the trig with llAtan2()  and constructing an orientation with a product of llAxisAngle2Rot(). llRotBetween often doesn't do what you think it does when used outside of simplified contexts.

  • Like 1
Link to comment
Share on other sites

@jak Scribe

mostly the above + the stuff on the wiki & llRotLookAt ...

default
{
    on_rez(integer start_param)
    {  llResetScript();       
    }
    state_entry()
    {  vector pos      = llGetPos();
       vector OwnerPos = llList2Vector(llGetObjectDetails( llGetOwner(),[OBJECT_POS]), 0);     
       llRotLookAt( llRotBetween( <1.0, 0.0, 0.0>, llVecNorm( <OwnerPos.x, OwnerPos.y, pos.z> - pos ) ), 1.0, 0.4 );
    }    
}

 

Edited by Xiija
  • Thanks 1
Link to comment
Share on other sites

If you're using the llRotBetween method, you might want to change the start axis it uses, i.e. the first vector: llRotBetween(<0, 1, 0>, end) or llRotBetween(<0, 0, 1>, end). Depends on the object and how it's built which way is the "visual front side", the x-axis i.e. <1, 0, 0> being towards the front is just a convention that isn't necessarily followed.

<0, 1, 0> points to the left of the object's local perspective, <0, 0, 1> points up. You can also use -1s to point backward, right or down.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 191 days.

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
 Share

×
×
  • Create New...