Lash Carver Posted July 14, 2015 Share Posted July 14, 2015 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 More sharing options...
Rolig Loon Posted July 14, 2015 Share Posted July 14, 2015 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 More sharing options...
Lash Carver Posted July 14, 2015 Author Share Posted July 14, 2015 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 More sharing options...
Rolig Loon Posted July 15, 2015 Share Posted July 15, 2015 Oh! Well then what you need is super easy. You want to script a follower. See the example at http://wiki.secondlife.com/wiki/LlMoveToTarget#Examples All you'll need to feed it are the avatar's position and rotation, which your sensor will give you as llDetectedPos() and llDetectedRot(). Link to comment Share on other sites More sharing options...
Lash Carver Posted July 15, 2015 Author Share Posted July 15, 2015 aaaaaand if it's non physical? lol Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 15, 2015 Share Posted July 15, 2015 Well... Make it physical? Or use a fast timer and do it all with SLPPF PRIM_POSITION and PRIM_ROTATION. It would be more jerky looking, but it would work. Link to comment Share on other sites More sharing options...
Lash Carver Posted July 15, 2015 Author Share Posted July 15, 2015 yes that is what I want. I just need the calculation for jumping it into position with the correct rotation using SLPPF. Is that something you can help with? Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 15, 2015 Share Posted July 15, 2015 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 More sharing options...
Lash Carver Posted July 15, 2015 Author Share Posted July 15, 2015 Yes I know that part. Like I mentioned though, I don't want it inside of me. I was hoping to calculate (about) where my right shoulder would be. That is the part I need help with. Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 15, 2015 Share Posted July 15, 2015 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 More sharing options...
Lash Carver Posted July 15, 2015 Author Share Posted July 15, 2015 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 More sharing options...
Rolig Loon Posted July 16, 2015 Share Posted July 16, 2015 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 More sharing options...
Recommended Posts
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