Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Am I insane? llGetPos() + llRezObject

OneBigRiver Stork
Diversity matters
Join date: 29 Mar 2006
Posts: 44
04-26-2006 17:05
I'm having some very weird results with rezzing an object from an attachment. Here is the code snippet:
CODE

vector apos = llGetPos();
rotation arot = llGetRot();
vector pos = apos ;
rotation lrot = llEuler2Rot(DEG_TO_RAD*<319.6,53.85,(308.55 - 35.0)>)*llGetRot();
vector vel = <0, 0, 0>;
llRezObject("OBRSpearProjectile", pos, vel, lrot, 0);


I would expect the center of the object to go through the center of my avatar, as GetPos() should return my avatar's position. What I am finding, however is that the object is consistently rezzing 0.15 north and 0.15 West of my center! If I am facing North, it rezzes in front and to the left of my avatar. If I am facing South, it appears behind and to the right of my avatar.

Am I losing my mind?

I am trying to make a spear that can be thrown as a projectile. To get this effect I turn my attached spear invisible, then rez a fake spear (the projectile version) in the same approximate location as my hand. While this cannot be made to look perfect (since animations are client side) I want to do the best that I can. What is driving me crazy is that as the script is now, if I face north, it looks great. If I face south, it looks like the spear is appearing 1/3 of a meter away from my hand! This makes no sense to me at all. :)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-26-2006 18:09
Is it phantom? if it's not, it will push your av out of the way.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Zermes Granville
Registered User
Join date: 6 Apr 2006
Posts: 17
I thought so too
04-26-2006 19:08
I am having a similar problem. Recently moved FROM Sunset City sim, to Sunset Beach sim, had a script started to rez a table at set coords.... simple really......

default
{
state_entry()
{

}

touch_start(integer total_number)
{
llRezObject("BarTable1",<242.898,121.683,22.114>, ZERO_VECTOR,<0.00000, 0.00000, -0.99833, 0.05777>,1);
llSleep(1);
llRezObject("BarTable1",<243.226,129.833,22.114>, ZERO_VECTOR,<0.00000, 0.00000, -0.99833, 0.05777>,1);
llSleep(1);
llRezObject("BarTable1",<245.715,125.965,22.114>, ZERO_VECTOR,<0.00000, 0.00000, -0.99833, 0.05777>,1);
}
}





After the move, the script did not rez the item at the set coords, it was off by almost .38 in any direction. the Z vector as shown above, should br 22.114, but when the item rezzes its at 22.692, and BELOW the floor its to be on.

Have even copied the script into a new item and replaced the object and get the same result
Jigsaw Partridge
A man of parts
Join date: 3 Apr 2005
Posts: 69
04-26-2006 21:35
Does the offset position change according to the position and/or rotation at which the object is attached to the avatar? You might have to compensate for these somehow, they can be obtained using llGetLocalPos() and llGetLocalRot() in the root prim.
OneBigRiver Stork
Diversity matters
Join date: 29 Mar 2006
Posts: 44
04-27-2006 07:35
From: Strife Onizuka
Is it phantom? if it's not, it will push your av out of the way.

Yes, it was phantom. Phantom, no phys, temporary on rez.
OneBigRiver Stork
Diversity matters
Join date: 29 Mar 2006
Posts: 44
04-27-2006 07:36
From: Jigsaw Partridge
Does the offset position change according to the position and/or rotation at which the object is attached to the avatar? You might have to compensate for these somehow, they can be obtained using llGetLocalPos() and llGetLocalRot() in the root prim.


Hmm. It *shouldn't* vary on that, but I haven't checked. llGetPos from an attachment is *supposed* to give the avatar's position. Then llSetPos should be in world coordinates (because the new item is not linked to or attached to anything).

Edit: I will try to do some experiments tonight and see if I can see differences based on the LocalPos and LocalRot.
OneBigRiver Stork
Diversity matters
Join date: 29 Mar 2006
Posts: 44
04-27-2006 07:50
From: OneBigRiver Stork
Hmm. It *shouldn't* vary on that, but I haven't checked. llGetPos from an attachment is *supposed* to give the avatar's position. Then llSetPos should be in world coordinates (because the new item is not linked to or attached to anything).

Edit: I will try to do some experiments tonight and see if I can see differences based on the LocalPos and LocalRot.


Attachment position has no effect on the final position. I tried moving the attachment far from my body, but the rezzed object appeared in exactly the same place.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
04-27-2006 08:11
What about attaching it to a different point?
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
04-27-2006 17:18
Is the spear linked? If so, are you looking at the geometric center of the object as the point which should rotate? (Geometric centers can turn out to be in a weird place when you're using cut prims etc.)
If not, either use llRezAtRoot and add another root prim at the place you want as the center. Or compensate your rotation take the offset with the geometric center into account.

Also, are you using mouselook while throwing? Mouselook changes the behaviour of llGetRot to give the rotation of the 'head' instead of the rotation of the hip (avatar), as i recall.
_____________________
Starax Statosky
Unregistered User
Join date: 23 Dec 2003
Posts: 1,099
04-28-2006 01:22
You're never going to make a good hunter with that spear.

There was a strange bug in SL that causes llDetectedRot() and llGetRot() to return the wrong rotation of an avatar. This only occurs after teleporting into certain sims.

Your problem could be related to that. Try throwing a spear in another sim. But not my sim!!
The Spork
Nobody
Join date: 8 Feb 2006
Posts: 100
04-29-2006 09:46
LOL That explains the spear I found under my floor. :D
_____________________
Thank You For Playing!
The Spork