Jump to content

Positioning a prim with llSetPos()


Asimos
 Share

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

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

Recommended Posts

I have attached a prim on pelvis. Prim Local position is <0,0,0> (so I do not have to worry about small deviations from the center)

I want to reach a target at Global Position <123.5, 130.0, 20.0>.

My avatar is at Global Position <120.0, 125.0, 21.0>.

My basic math tell me that the following should approximately place the prim on the center of the target. My avatar is facing the target (so I do not have to worry about rotations at this point in time). Yet is does not work. Any ideas why?

...

vector target = <123.5, 130.0, 26.0>;
vector avatar = <120.0, 120.0, 26.0>;
llSetPos(target - avatar);

...

Link to comment
Share on other sites

Well, for one thing, you are too far away.  You can't move anything with llSetPos more than 10 m.

Beyond that, when you use llSetPos in an attachment, the position vector is a local vector, relative to the attachment point, not relative to the avatar's global position.  See http://wiki.secondlife.com/wiki/LlSetPos#Coordinate_Frame .  The same is true for rotations and llSetRot.  See http://wiki.secondlife.com/wiki/Rotation#Single_or_Root_Prims_vs_Linked_Prims_vs_Attachments .

Link to comment
Share on other sites

Actually I am NOT that far. With those coordinates, I shouldn't be more than 11m, and I chose those coordinates on purpose (Delta X=3.5, Delta Y=10m, Delta Z=0) to stimulate a more in-depth disuction with the forum on llSetPos and its limits. Also, I chose for simplicity the prim be positioned on the center of the avatar with local coordinates <0,0,0>.

But let me change the coordinates if that helps to refocus the discussion on the real issue . With the following coordinates the distance is well below 10m, yet it does not work:

vector target = <123.5, 130.0, 26.0>;
vector avatar = <120.0, 129.0, 26.0>;
llSetPos(target - avatar);


A fast diagram will help you understand that, for approximate positioning, what I'm doing is good enough (please keep it simple, and as I said, localvector=<0,0,0>. Once I understand why that does not work, then adding the local vector is trivial).

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2849 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...