Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Accurate avatar facing

Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-16-2007 06:41
This is a problem I've had before, and is possible a probably that may not be solved easily:

I'm attempting to fire a projectile from an avatar, in this specific case a projectile to correspond to a particle effect.

Problem is; the rotation returned by llGetRootRotation() from an attachment doesn't seem to accurately reflect the angle the avatar is actually facing in. I'm not talking about during fancy animations or anything, but simply standing still and rotating to face a new direction, the rotation can be as much as around 25 degrees off comapred to the particle effect.

Has anyone found a way to more accurately get the rotation of an avatar? The attachment I'm using for the particles is the stomach (to mimic the hips/pelvis since they're the 'root' of the avatar).
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
06-16-2007 08:01
I've never used llGetRootRotation() in an attachment, so I am kind of curious to know just how far off it is.

I have always used plain 'ol llGetRot(), which seems pretty accurate for my purposes. Well, at least it's accurate in Mouselook mode. It's probably quite accurate in third person as well, it seems that in third person mode the viewer doesn't even align your avatar with it's actual direction of facing.

The items that I create are attached to the hands (swords and other melee weapons), and llGetRot() always returns the current rotation of the avatar itself. It's not necessary to attach an item to the stomach to get that information.

.
_____________________
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-16-2007 08:17
llGetRot() and llGetRootRotation() actually return the same result for attachments, the reason I'm using the stomach for the attachment is that if the Z axis (basis of particle systems) is facing directly forward, then it will fire directly forward from the avatar's rotation, at least, that was the theory. It's also the avatar's centre when standing, and the effect produces a kind of cylinder firing forwards.

I'm thinking the issue is that the rotation may take into account projected rotation, so if you're rotating, then the rotation returned will be ahead of the avatar's actual rotation. Moving forward a step or two will always solve the inaccuracy. As the avatar's body is now facing the same way that it itself is facing.
ie; I'm turning 45º but then correct and end up at about 30º, the shots will fire 15º off because while the avatar may not have rotated the full 45º, it's rotation still appears to be use that.

It seems like the result for llGetRot() and llGetRootRotation() therefore is the rotation of the avatar's head, which moves ahead of the rest of the body, and is what you control in mouselook.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-17-2007 08:14
I suspect you're seeing the difference between the agent's rotation in the sim as reported by llGetRot(), etc., and the apparent rotation of the animated avatar in the viewer. A recent thread (/54/a6/190954/1.html) may be relevant, especially Lex Neva's comment.
Adrian Zobel
Registered User
Join date: 4 Jan 2006
Posts: 49
06-21-2007 17:13
I think the problem is that the way your avatar is facing on your screen is only an approximation. The value returned by llGetRootRotation would be the real, official facing. Some of the other people in the same sim will see your avatar facing exactly that way, even though you don't.

I saw a bowling game in SL once that would rez an arrow over your head and face it in the direction given by llGetRootRotation -- so that you could see what direction your avatar was really facing, not just the way your avatar is drawn on your screen.

I doubt there's any real solution, short of downloading the SL viewer source code and altering it to draw your avatar more accurately on your own screen.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-22-2007 10:11
Well since it's a fairly annoying issue I decided I'd post it to the Jira for LL or any enterprising developer to have a go at, since all it really requires is to have the avatar continue turning till they're actually facing the right way, rather than stopping when they're "close enough".

https://jira.secondlife.com/browse/VWR-1331
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)