Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attachment detecting sit/stand

Lemieux Primeau
Registered User
Join date: 25 Oct 2006
Posts: 49
09-23-2007 10:46
I am trying to make something attached to the pelvis stay reasonably parallel to an AVs leg. But I am not concerned with every little angle change of the leg - just when it goes from being roughly parallel to Z to being roughly perpindicular to Z. So, basically, like when the AV goes from standing to sitting down and vice versa.

What is the best approach for this?

I have attached a prim to the upper leg and am having it report its rotations so that I can see what is going on. The idea is to have the leg prim use a rot target and then, when it gets within range, whisper to the pelvis prim what its rotation is and the pelvis prim would change its rotation to match the leg prim's.

Does this seem good? Or is there a better way to do it?

Assuming this is a good way to do it - then I have a question about the rotations I am seeing. In the leg prim, on the touch_start event, I did the following:

llOwnerSay((string)(llRot2Euler(llGetLocalRot() * DEG_TO_RAD))

When the AV is standing or sitting, I get <0,0,0>

So then I tried:

llOwnerSay((string)(llRot2Euler(llGetRot() * DEG_TO_RAD))

When the AV stands, the x and y elements are 0 and the z element changes depending on how the AV is rotated around z (like with the left / right control).

So this looks promising. When the AV sits, the x and y values change. However, the first thing that doesn't make sense to me is that the value returned for them is a fraction of a degree, like 0.05623 or 0.02974 or something similar. I would expect them to be a much bigger number like 90 or there abouts.

But the second problem when the AV sits is that the x and y are different based on the z. That is, if I have several of the same chairs around the room, all rotated differently around the z, my x and y will be different for each one I sit in.

In this case, how do I know how to set my target so that it supports the AV sitting down at any rotation around z?

Any help would be greatly appreciated. While I feel like I am getting close, I am definitely suffering from a rotation based headache :)
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
09-23-2007 11:44
From: Lemieux Primeau
I have attached a prim to the upper leg and am having it report its rotations so that I can see what is going on.
This won't work because scripts run on the server (sim) and animations run on the client. Attachments can only determine the position and orientation of the avatar, not their individual positions and orientations, since that information is not sent to the server, and will indeed vary from client to client most of the time.
Lemieux Primeau
Registered User
Join date: 25 Oct 2006
Posts: 49
09-23-2007 12:24
Ah, excellent, Deanna, that explains alot. Thanks!

Are there any other approaches to my solution then?

Is there a way to detect when the AV sits and unsits if my script is in an object attached to the AV but is not the object that is being sat on?

Though I haven't tried it yet, it appears that llGetAgentInfo might be able to reliably tell me if the agent is on an object or "sitting". But what event can I use to detect when this happens?

If I could trap that, I could just hope that the animation they have is a conventional sitting in a chair position and just force my rotation accordingly. In other words, just assume that the legs are perpindicular to Z, and rotate my prim to the same. This would probably end up working 90% of the time at least.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
09-23-2007 22:01
From: Lemieux Primeau
Though I haven't tried it yet, it appears that llGetAgentInfo might be able to reliably tell me if the agent is on an object or "sitting". But what event can I use to detect when this happens?
It appears polling with a timer is about the only option. Unfortunately, changed( CHANGED_LINK ) isn't raised in attachments when the avatar sits/unsits.
Lemieux Primeau
Registered User
Join date: 25 Oct 2006
Posts: 49
09-24-2007 18:10
Thanks, Deanna - sounds like the timer is the way to go.