Avatar Attachment moving?
|
Viny Bailey
Registered User
Join date: 13 Dec 2008
Posts: 5
|
10-26-2009 13:27
Hey all,
Here's my problem: I got an attachment on my avatar. Let's say a cube on right hand. I got a prim rezzed on ground. Let's say a sphere. I want the cube (attached to me) to go on the exact sphere (rezzed on ground)position, with no offset or with a given offset.
Here's basically what i've tried:
The sphere (rezzed on ground) is touched then send its llGetPos() vector to the cube (attached to my avatar). The cube receives the message and is effectively converting it to a vector.
Now I touch the cube, my attachment. It detects its llGetPos() vector (Not Local). It compares if its position is the same as the sphere's position. Its not, so it tries to move to that position. BUT nothing happens. I tried several things (llMoveToTarget, llSetPos) but it does not do anything. It only works WHEN THE CUBE IS NOT ATTACHED to my avatar. I aint no script guru, and this time i cant seem to get what i want, so I would need you useful help here. Thx everyone for ur answers, have a good one.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-26-2009 14:06
From: http://lslwiki.net/lslwiki/wakka.php?wakka=attachment •When an object is attached, functions that affect objects linked to the attachment (llCreateLink, llBreakLink, and llBreakAllLinks) fail silently when called. In other words, you're not going to be able to link an object to an attachment. You have to detach it first. You can't do it manually with the Edit tools, either. Incidentally, the position and rotation of an attachment are always local to the avatar.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
10-26-2009 14:16
Hmm. Rolig, I don't think he's trying to relink, he's just trying to reposition the attachment.
Viny, a couple of things about the commands you mention.
> llMoveToTarget will only work if the attachment is physical, in which case moving it will move your avatar as well, I believe.
> You have to be careful when using llSetPos with attachments. For attachments, llSetPos requires coordinates in object-local coordinates, but llGetPos will always return region coordinates. llGetLocalPos may help with the arithmetic.
It may be that the vector arithmetic you're using is not quite right, and the SetPos command is silently failing when asked to move to an impossible place. If you are comfortable simply posting the code (or part of it), we may be able to help more explicitly.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-26-2009 14:39
Well........ OK, he's not trying to link the cube and the sphere. I overreached.  Still, the OP is trying to make an attached cube move to the position of an unlinked sphere on the ground. If he used the right math (coordinates local to the av), he might be able to accomplish that, but it would be a temporary victory ... good only until the avatar twitches. The only way to make the cube stay where he moved it is to detach it first and then move it.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Viny Bailey
Registered User
Join date: 13 Dec 2008
Posts: 5
|
10-26-2009 15:14
K, first, thx guys trying to help. i got the following code moving and yeah , even when attached. But it still does not work... I rezzed an object at, for example <10,20,30> on a sim, then i attached my cube, typed in chat <10,20,30>, and the attachment moves but dont reach <10,20,30>. ////// THIS SCRIPTIS IN THE ATTACHMENT string vectorstring; vector actual; vector target; default { state_entry() { llListen(0, "", llGetOwner(), ""  ; } listen(integer channel, string name, key id, string message) { // here I'm simulating a rezzed object sending its llGetPos() vector // to the attachment. i actually type the vector in chat. actual = llGetPos(); vectorstring = llGetSubString( message, 0, 34 ); target = (vector)vectorstring; if(actual != target) llSetPos(target); } }
|
Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
|
10-26-2009 15:43
llSetPos is limited to moves of no more than 10m.
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-26-2009 17:05
I'm a bit confused. What's supposed to happen to the avatar when the attached cube moves closer to the sphere? Should it drag the avatar along with it (like a collar does) or does the avatar stand there watching the cube move on its own towards the sphere?
|
Viny Bailey
Registered User
Join date: 13 Dec 2008
Posts: 5
|
10-28-2009 09:57
Innula, the avatar is not supposed to move. Only the attachment needs to reach a "target", rezzed on ground.
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
10-28-2009 10:16
From: Viny Bailey actual = llGetPos(); vectorstring = llGetSubString( message, 0, 34 ); target = (vector)vectorstring; if(actual != target) llSetPos(target);
Looks to me like your problem is that llGetPos is giving you coordinates in region coordinates, so presumably you are typing in region coordinates to compare with it. BUT llSetPos is assuming that you're giving it local coordinates, relative to the attachment point. After you detect that that actual != target, then you should: > Determine the difference between the actual and target locations, I think a simple subtraction would do. > do an llGetLocalPos ( http://lslwiki.net/lslwiki/wakka.php?wakka=llGetLocalPos) and apply that difference to it. > NOW do your llSetPos with that value.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-28-2009 10:30
But it's still going to move if you so much as sneeze. The attachment is still attached to the avatar, not free to move on its own and not related to the object on the ground in any way. Or maybe I'm missing something here ..... 
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
10-28-2009 15:20
From: Rolig Loon But it's still going to move if you so much as sneeze. Oh, definitely. *leans back in chair and smiles absently* Long ago in a sim that no longer exists, I was short on prims, but I wanted a really lush garden. One thing I thought about doing, and we actually tossed the idea around in the forums, was using a 'camper' and attaching the entire garden to him. He'd be movelocked and in a rigid animation way below ground, his name might be "AFK Gardener", and I'd only bring him online when I wanted to have friends over. Plants are phantom anyway, so hey. Never bothered to do it, but if the avatar is completely motionless your movable prim will be too. 
|