Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting the actual position of a child

VietnamWar Memorial
Registered User
Join date: 17 Dec 2005
Posts: 2
12-22-2005 10:32
I'm currently in the midst of creating an utterly retarded object that's basically a cannon stuck onto a helmet. The problem is that I'm trying to have cannon balls appear to be shooting out of the cannon, but when I call for them to be rezzed they come out of the middle of my avatar. I've tried various combinations of llGetPos, llGetLocalPos, and llGetRootPosition to find the actual position of the cannon, which is set as a child of the helmet which is attached to my skull. The weird thing is that llGetPos and llGetRootPosition seem to be looking at the exact same spot, and after seeing someone notice the same thing, I think that the avatar is being treated as the root while the helmet becomes a child. llGetLocalPos returns a different vector, which I hoped I could just add to whatever comes out of llGetRootPosition, but when I tested this it didn't really make any noticable difference in the spot where the cannonball rezzed. Any ideas?
Oasis Perun
Registered User
Join date: 2 Oct 2005
Posts: 128
12-22-2005 10:49
have you tried tweaking with the "pos" parameter in llRezObject?
// rez something 2m above us
CODE
llRezObject("something", llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 42);
CODE


or could you post part of your code here so somebody can maybe see the problem?
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
12-22-2005 10:55
The server doesn't know anything about where any specific part of your avatar is.

The only way to have objects appearing to shoot out of any part of your avatar is to use particles.
VietnamWar Memorial
Registered User
Join date: 17 Dec 2005
Posts: 2
12-22-2005 11:07
From: Oasis Perun
have you tried tweaking with the "pos" parameter in llRezObject?
// rez something 2m above us
CODE
llRezObject("something", llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 42);
CODE


or could you post part of your code here so somebody can maybe see the problem?


I tried but it's not really a permanent solution since part of the point of sticking it on my head was that it would point wherever I was looking and then the cannonball would shoot out of it. If I wanted to be both simple about it and more vulgar than my getup already is I could've just attached the cannon to my pelvis.

As for the code, it's so hacked apart at this point I doubt it would be of much use. IIRC, the call was something like
CODE
llRezObject("cannonball", llGetPos(), velocity, rotation, 0);
with direction coming from llGetRootRotation and velocity coming from llRot2Fwd. The ball shoots out very nicely, and I'm pretty sure it's going out on the proper angle (I can't be sure since I'm in mouselook when I shoot but I'm pretty sure); the problem is that it's coming out from the wrong place and since the front of the cannon isn't fixed in one place in relation to wherever llGetPos points to I can't just manually offset the vector. At least I don't think I can.

From: Argent Stonecutter
The server doesn't know anything about where any specific part of your avatar is.

The only way to have objects appearing to shoot out of any part of your avatar is to use particles.


So then what's the point of llGetLocalPos? It's my understanding that that returns the position of a child relative to it's root, so assuming it works like I think it does shouldn't I be able to just add the two vectors together to get the rez position I want?
Candide LeMay
Registered User
Join date: 30 Dec 2004
Posts: 538
12-22-2005 11:15
llGetLocalPos() returns the attachment's position relative to the attach point. Since avatar animation is completely client side, there's no way to get the global position of an attachment on the server (where the script runs). You can manually tweak the numbers to make it more or less work for your own avatar, but it won't look ok if you give it to other people (unless they are your clones :))

(llGetLocalPos() works as expected on non-attachments)
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
12-22-2005 17:53
heh, I laughed at the title of this thread. Personally I'm in favor of radio collars o.O.
_____________________