Jump to content

Move prim to AV's shoulder


Lash Carver
 Share

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

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

Recommended Posts

I'm trying to make a script that will move a prim to an avatar's shoulder (or somewhat in the area of...) but I'm not sure how to do this when you throw in rotations. I need to jump the prim to a location based on the AV's rotation, to always land near the right shoulder.

help? Thanks in advance!

Link to comment
Share on other sites

It depends on where the prim is jumping from.  If it's not already attached, you can use llAttachToAvatar or llAttachToAvatarTemp to aim it to a specific attachment point.  If you've already set the prim on your own shoulder, it will remember the position relative to the specified attachment point and you're done.  It's harder if the prim is already attached to you.  In that case, you don't know the position of the new spot unless you know the size/shape of the avatar.  The mechanics of moving it are not the hard part, because when you use llSetPos on an attachment, the specified position is a local coordinate relative to the attach point. The hard part is knowing exactly how far to move it and in what direction.  Rotation is potentially less of a challenge.  If the object is attached, llSetRot sets a rotation relative to the avatar's rotation -- that is, a local rotation -- which is what you want.

Link to comment
Share on other sites

Thanks for the reply but I'm talking about moving to the shoulder WITHOUT being attached. Sorry I didn't specifically say that. I need to get the avatar's position and rotation, then some sort of calculation would tell me where his right side would be...etc

Link to comment
Share on other sites

But the answer is the same, whether you use llMoveToTarget or SLPPF.  In both cases, you are moving your object to llDetectedPos(0) and setting the rotation to llDetectedRot(0), applying whatever constant offset seems appropriate to each.

Link to comment
Share on other sites

And as I said at the start, you can't calculate that offset because you have no way of knowing where your right shoulder is, relative to any other part of your body, without knowing the size and shape of your body.  Each av is different.  Therefore, you will have to simply guess at a position and rotation -- actually determine it by experimentation on a "normal" av -- and simply plug them in as preset values.  You can write the script in such a way that a different user can plug in his own vector and rotation if your presets aren't close enough.

Link to comment
Share on other sites

I already scripted the part where it gets the person's size (width and height being most important). That part I can figure out on a trial basis. I just don't understand how to calculate an offset based on the person's rotation. can you give me a vague idea of the calculation I would need?

Link to comment
Share on other sites

Personally, I would probably start by just using the person's own rotation without applying a correction.  Rotation of the follower should probably be pretty much the same from one av to another.  You'll always want the thing to face "forward", for example, so you just feed it the av's rotation and it's automatically doing just that.  If you always want the thing to look in the av's ear, apply a constant correction of llEuler2Rot(<0.0,0.0,PI/2>) or something.  You avoid having to calculate anything.

Link to comment
Share on other sites

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