Jump to content

change animation height


Zousug Corvinus
 Share

You are about to reply to a thread that has been inactive for 366 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

The person who sits on your object becomes the last link in its lnkset, so you can move that person with

llSetLinkPrimitiveParams( llGetNumberOfPrims(), [ PRIM_POS_LOCAL,          ] );

and then put your new local position in the blank space.  And of course, you can change that position, depending on which anim is triggered.

  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, Rolig Loon said:

The person who sits on your object becomes the last link in its lnkset, so you can move that person with

llSetLinkPrimitiveParams( llGetNumberOfPrims(), [ PRIM_POS_LOCAL,          ] );

and then put your new local position in the blank space.  And of course, you can change that position, depending on which anim is triggered.

Hi thanks for the reply,

When i save the script i get a (0,26) Error Syntax error  even if i place the above in.. is that just because im not sitting on it at the time? sorry its been awhile with scripting and its early morning lol

Link to comment
Share on other sites

Well, if the person is not sitting, then she's obviously not in the linkset yet, so that doesn't work.  I assumed you were trying to adjust sitting position.  You can't ever adjust the position of an avatar directly.  You can only adjust the position of something an avatar is sitting on or wearing.

Link to comment
Share on other sites

4 minutes ago, Rolig Loon said:

Well, if the person is not sitting, then she's obviously not in the linkset yet, so that doesn't work.  I assumed you were trying to adjust sitting position.  You can't ever adjust the position of an avatar directly.  You can only adjust the position of something an avatar is sitting on or wearing.

oh it is for when sitting i just wasnt sitting on it while i was writing the script haha.

I will play with it and get back to you *again early morning and been awhile lol* thank you for your help.

Link to comment
Share on other sites

7 hours ago, Rolig Loon said:

Well, if the person is not sitting, then she's obviously not in the linkset yet, so that doesn't work.  I assumed you were trying to adjust sitting position.  You can't ever adjust the position of an avatar directly.  You can only adjust the position of something an avatar is sitting on or wearing.

just an update, works perfect thank you ^.^

Link to comment
Share on other sites

10 hours ago, Rolig Loon said:

Well, if the person is not sitting, then she's obviously not in the linkset yet, so that doesn't work.  I assumed you were trying to adjust sitting position.  You can't ever adjust the position of an avatar directly.  You can only adjust the position of something an avatar is sitting on or wearing.

Hey,

So it works *lowers me down cause the animation by default is high* but i need to change it so its a little higher off the ground.  *ignore the messy code sorry*

the last line llsetlinkprimitiveparamsfast bit, iv tried changing the numbers but it isnt changing the height any, also *im sitting on the item* still getting a Syntax error on 0,25 *which is just after the ( in first line*

 

llSetLinkPrimitiveParams(llGetNumberOfPrims(), [ PRIM_POS_LOCAL,] );  // when avatar sits it becomes the last child on the linkset

default
{
vector size = llGetAgentSize(llAvatarOnSitTarget()); // we measure the avatar size
float adjustement = (size.z / 2 );  // size.z is avatar height, pelvis is halfway the avatar
float avup = (adjustement + ( size.z/10)) + 0.08; // half of avatar + one tenth of avatar + your own tweak (depends on various things, so you have to test what works for you)
llSetLinkPrimitiveParamsFast(agentlinknum,[PRIM_POS_LOCAL,<0,0,avup>,PRIM_ROT_LOCAL,llEuler2Rot(<0,0,0>)]); // here we move the avatar to the new position, the rotation part is the target rotation in euler 
}

 

Link to comment
Share on other sites

The syntax error on the first line is because there needs to be a quantity following PRIM_POS_LOCAL but I cannot see the purpose of this line, for now comment it out. ( Actually, if it were changed to get instead of set and the comma removed after PRIM_POS_LOCAL it would then return something you will be needing to use, the position of the last child prim).

If no avatar is sitting on the target, size will be ZERO_VECTOR, so have an if(  size != ZERO_VECTOR ) test in there.

if size is non-zero, then set agentLinknum to llGetNumberOfPrims();

 

Having caluclated the adjustment for height, you need to get the avatar's actual local position and then add the offset to that, then use this figure in the set primitive params, so after your float avup, insert 

vector whereAreThey = llList2Vector( llGetLinkPrimitiveParams(agentLinknum, [PRIM_POS_LOCAL]), 0);

whereAreThey += avup;

// then use WhereAreThey as the value for PRIM_POS_LOCAL]

 

 

Edited by Profaitchikenz Haiku
  • Like 2
Link to comment
Share on other sites

There are two ways to detect somebody seated on an object, the OP has used the one that is most common, llAvatarOnSitTarget(), but it is also possible to sit on a prim that has no defined sit target. In that case a different method is needed to work out if somebody is sitting in an object. The second method has one distinct advantage over the first, it will return the key of the seated avatar. It is confusing that in order to actually work with a seated avatar, the second method must be used since the first method only gives you a key and then requires additional details.

To demonstrate, rezz three default cubes.

Put this script inside the first:

// test avatar on sit target and highest link number

key owner;

default
{
    state_entry()
    {
        owner = llGetOwner();
        llOwnerSay((string) llGetNumberOfPrims());
    }

   changed(integer change)
   {
       if( change & CHANGED_LINK)
       {
           integer prims = llGetNumberOfPrims();
            key avatar = llAvatarOnSitTarget();
            string name = "none";
            if( avatar != NULL_KEY) name = llKey2Name(avatar);
            llOwnerSay("Prims " + (string) prims + " seated " + name);
            if( prims > 1)
            {
                key topPrim = llGetLinkKey(prims);
                vector size = llGetAgentSize(topPrim);
                vector where = llList2Vector(llGetLinkPrimitiveParams(prims, [PRIM_POS_LOCAL]), 0);
                if( size != ZERO_VECTOR) llOwnerSay("Seated " + llKey2Name(topPrim) + " at " + (string) where );
            }
        }     
    }
}

It will give this output when sat on and then stood up from


[15:44] testSit: Prims 2 seated none
[15:44] testSit: Seated Profaitchikenz Haiku at <0.34000, -0.08179, 0.87997>
[15:44] testSit: Prims 1 seated none

Notice that llAvatarOnSitTarget() has returned NULL_KEY for both changed events, but checking the highest child number's key is a reliable way of finding out who is sitting, and then allows getting other useful information such as their relative position to the root.

 

put this script inside the second:

// test avatar on sit target and highest link number

key owner;

default
{
    state_entry()
    {
        owner = llGetOwner();
        llSitTarget(<0.0, 0.0, 0.4>, ZERO_ROTATION);
        llOwnerSay((string) llGetNumberOfPrims());
    }

   changed(integer change)
   {
       if( change & CHANGED_LINK)
       {
           integer prims = llGetNumberOfPrims();
            key avatar = llAvatarOnSitTarget();
            string name = "none";
            if( avatar != NULL_KEY) name = llKey2Name(avatar);
            llOwnerSay("Prims " + (string) prims + " seated " + name);
            if( prims > 1)
            {
                key topPrim = llGetLinkKey(prims);
                vector size = llGetAgentSize(topPrim);
                vector where = llList2Vector(llGetLinkPrimitiveParams(prims, [PRIM_POS_LOCAL]), 0);
                if( size != ZERO_VECTOR) llOwnerSay("Seated " + llKey2Name(topPrim) + " at " + (string) where );
            }
        }
    }
}

It will give the following output:


[15:51] testSitTarget: Prims 2 seated Profaitchikenz Haiku
[15:51] testSitTarget: Seated Profaitchikenz Haiku at <0.00000, 0.00000, 0.75000>
[15:51] testSitTarget: Prims 1 seated none

It now gets the name of the seated avatar from the result of llAvatarOnSitTarget(), and returns a different local position which has zero offset in the X and Y, as specified in the sit target vector,

 

Finally, in the third prim, put the second script but amend  target line to read  llSitTarget(ZERO_VECTOR, ZERO_ROTATION);

The output is now 

[15:56] testZEROSitTarget: Prims 2 seated none
[15:56] testZEROSitTarget: Seated Profaitchikenz Haiku at <0.34000, 0.05109, 0.87997>
[15:56] testZEROSitTarget: Prims 1 seated none

Notice that it is now behaving identically to the default prim with no sit target defined.

The main reason for using llAvatarOnSitTarget is to get the avatar key to then request permissions to animate etc. However, the most useful information is obtained by querying the highest child prims to test for an avatar in the link set.

I am tempted to say that llAvatarOnSitTarget is redundant, since you can still perform all the permission checks using the key obtained by the second method. I am sure somebody will step up and explain why llAvatarOnSitTarget() is still vitally important :)

  • Like 2
Link to comment
Share on other sites

1 hour ago, Profaitchikenz Haiku said:

I am tempted to say that llAvatarOnSitTarget is redundant, since you can still perform all the permission checks using the key obtained by the second method. I am sure somebody will step up and explain why llAvatarOnSitTarget() is still vitally important :)

llAvatarOnSitTarget can help you identify the person who is in the properly positioned seat. (It's not necessarily the person who sat first, or who comes first in link numbers.)

Link to comment
Share on other sites

7 hours ago, Wulfie Reanimator said:

llAvatarOnSitTarget can help you identify the person who is in the properly positioned seat.

That is sort of handy if you want to work out whether the object in question has ever had a sit pos defined and the script then removed, leaving behind just a prim-property (as opposed to zeroing the sit-pos), I suppose, provided you can determine from the returned avatar local position if it is in the default no-sit target position or not. That's easy when you have a bare-bones prim but a lot harder when it's a complex link set.

In the case of a multi-sitter scripted object, it's of virtually no value at all, because as you say it's not giving any sequential or positional information.

Going back to the OP's question though, I remember a set of magic numbers that allowed you to apply an offset based on the avatar's height, but when I last looked at it, it was unable to take into account extended feet such as Slink, or other bento feet, which lifted the avatar even more than the shoe heel and platform height method.

The method I see used more and more is to allow each sitter to adjust themselves via a menu, which of course requires using the second method of getting the link number and avatar local position for applying a subsequent offset. 

Link to comment
Share on other sites

7 hours ago, Profaitchikenz Haiku said:

In the case of a multi-sitter scripted object, it's of virtually no value at all, because as you say it's not giving any sequential or positional information.

Depending on the intention of the build, llAvatarOnLinkSitTarget() (along with PRIM_SCRIPTED_SIT_ONLY on non-seats) can be very useful, because it lets you define specific "spots" for sitting based on where the avatar clicked to sit rather than order. If done in a well thought out manner, you could for example, have a single-script bus, with several passenger seats and a driver's seat, and the driver could stand up and sit down at any point while other people are sitting and still remain the driver without pushing other sitters around as long as they sit on the prim/mesh representing the driver's seat. Passengers can change seats by standing and re-sitting on the specific seat they want rather than using an obtuse menu. etc. OTOH for something like a "couch" that would b a very obnoxious and unintuitive way of doing things. You probably don't want to stand up and sit on a different cushion for every other pose. So, normally makes the most sense for things with several different single-person spots that don't interact with each other too much, although you could also maybe group seats in pairs or something with a lot of script work.

Quote

getting the link number

We have OBJECT_LINK_NUMBER now; Huzzah!

Edited by Quistess Alpha
Link to comment
Share on other sites

2 minutes ago, Profaitchikenz Haiku said:

just went a-looking for that on the LSL portal but was joyless.

https://wiki.secondlife.com/wiki/LlGetObjectDetails it's 46 FWIW. Mostly does what you would expect it to given the name. It's would be better as a separate function IMO, but we take what we get. A lot of (increasingly less) recent changes to multi-functions are less well documented than they could be.

Link to comment
Share on other sites

 After sacrificing a Bronie and a Meeroo I was granted a vision by the gods but as far as I understand it, the script requesting this information has to be within the child prim in question, so I can't see how it would work from within the root of a link set. It would be interesting if it could be stuck inside an AO to allow the AO to override it's own sits to allow the scripted sat-upon thingy to do it's stuff.

 

ETA

Ok, it makes sense for me now, having got the avatar key, passing that into getObjectDetails with Object_link_number gives us the child index. I see a need for me to simplify some of the multi-sit scripts I've been tormenting some people with for months now, thanks indeed for the pointing-out.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

3 minutes ago, Profaitchikenz Haiku said:

After sacrificing a Bronie and a Meeroo I was granted a vision by the gods but as far as I understand it, the script requesting this information has to be within the child prim in question, so I can't see how it would work from within the root of a link set. It would be interesting if it could be stuck inside an AO to allow the AO to override it's own sits to allow the scripted sat-upon thingy to do it's stuff.

A) Can't quite test it at the moment, but

key ID = llAvatarOnLinkSitTarget(3); // if link #3 has a defined sit target, and an avatar is sitting on that link, return that avatar's ID.
if(ID)
{	integer link = llList2Integer(llGetObjectDetails(ID,[OBJECT_LINK_NUMBER]),0); // what link number are they in the link set?
}

seems like about the intended usage.

B) an AO has other methods of testing if their wearer is sitting, specifically:

key root = llList2Key(llGetObjectDetails(llGetOwner(),[OBJECT_ROOT]),0);
if(root!=llGetOwner())
{   // owner==wearer is sitting on an object, is the object scripted?
    if(llList2Integer(llGetObjectDetails(root,[OBJECT_RUNNING_SCRIPT_COUNT]),0))
    {   // wearer is sitting on a scripted thing, turn off AO.
    }else
    {   // wearer is sitting on a non-scripted thing.
    }
}else
{   // owner==wearer is not sitting, turn on AO.
}

 

  • Thanks 1
Link to comment
Share on other sites

I had a play inworld and I can see how it simplifies getting the link number of an avatar on a sit target. It doesn't aid in the other method of avatars sitting on objects with no sit target but that's already about as efficient a method as I can make it.

 

Reading through the snippet the OP first started working from I see that the formula is only for an avatar standing, not seated, but then reading through the other constants that llGetObjectDetails can take I was interested to see that Hover_height is available, and that had made me wonder if that would be a better offset to apply to an avatar that is going to sit on an object but appear to be standing on it? So something like half the avatar's height plus a magic fraction plus the hover height?

Link to comment
Share on other sites

3 minutes ago, Profaitchikenz Haiku said:

So something like half the avatar's height plus a magic fraction plus the hover height?

Back on-topic, I was perusing RLV doc a bit ago an came across an interesting old old thread: http://sldev.free.fr/forum/viewtopic.php?f=7&t=447

we also have the (Extremely unhelpfully named, took me forever to find it) new function llGetVisualParams() which might be helpful, It seems I made a test of it when it was newly released for sit-posiitoning, but my main observation was that: "Well placed sitting depends a lot on body fat, which is not an observable parameter." Your mileage may vary, and it might be more useful if it's for someone standing?

Link to comment
Share on other sites

Just had a play inworld to confirm that llGetAGentSize and llGetObjectDetails(avatar, [OBJECT_SCALE[]) return the same value for an avatar.

So the OP's request can be simplified to

 

   changed(integer change)
   {
       if( change & CHANGED_LINK)
       {
            key avatar = llAvatarOnSitTarget();
            if( avatar != NULL_KEY)
            {
                list details = llGetObjectDetails(avatar, [OBJECT_LINK_NUMBER, OBJECT_SCALE,PRIM_POS_LOCAL]);
                integer avNum = llList2Integer(details, 0);
                vector size = llList2Vector(details,1);
                vector where = llList2Vector(details,2);
                where.z += size.z * 0.5 + size.z * 0.1 + 0.08;
                llSetLinkPrimitiveParamsFast(avNum, [PRIM_POS_LOCAL, where]);
            }
            else // the avatar has left the building
        }
       
       
    }

A quick note to the OP, I have multiplied by 0.5 and 0.1 instead of dividing by 2 and 10, since division is always slower than multiplication because of the way computers  do arithmetic.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

25 minutes ago, Quistess Alpha said:

we also have the (Extremely unhelpfully named, took me forever to find it) new function llGetVisualParams() which might be helpful,

Looking at that, yes, it looks much better for working out where to place an avatar, particularly when there are standing or bending over poses. I'm guessing that you would use something like height - torso-length to determine where the fundament of the avatar is, but as you have alluded to, the thickness of the thighs would be the main determining factor as to how high or low the avatar is to go?

Link to comment
Share on other sites

5 minutes ago, Profaitchikenz Haiku said:

he thickness of the thighs would be the main determining factor as to how high or low the avatar is to go

Yeah I'd have to test it again, because my notes weren't' that great, but from what I recall, with respect to an avatar in the default sit position, changing your shape doesn't actually move your center that much if at all, which good news for chairs, if a specific offset works for one person it should be ~roughly correct for most people.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 366 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...