Jump to content

Stopping KFM when standing up: how to stop avatar being flung around


Emma Krokus
 Share

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

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

Recommended Posts

I am using a KFM (keyframed motion) script for a rocking chair.

I managed to make the rocking start when the script detects the avatar as an added link as they sit down. 

Touching the chair changes to the next pose. (This function is contained in a separate script.)

On standing up I am stopping the kfm animation but finding that the avatar gets displaced when standing up - quite dramatically in some instances. 

I would be grateful for some advice with this please. Thank you!

Emma :)

 

Link to comment
Share on other sites

That's not easy.  Probably not even possible.  I suspect that the seat on that chair is inside the mesh bounding box.  When you stand up, you're forced out of it in some random direction.  The only thing I can think of that might work is to make the chair itself the child of a transparent root cube that holds the script, and then make the chair physics type NONE.  Give it a shot.

Link to comment
Share on other sites

Hi Rolig :),

Thank you.

I tried your approach (also setting the prims to phantom) with adding another prim as root so the chair itself could be physics type NONE. 

Unfortunately my avatar is still being flung about...

Anyone else have any ideas please?

Thanks.

Emma :)

 

Link to comment
Share on other sites

I can only grasp at straws ....  I assume that you have a changed event to test when someone has sat down.  When someone stands up, do you tell the script to kill the KFM ( llSetKeyframedMotion([],[]);  )?  Your own anim should cancel when you stand, but the KFM activity won't know to make the rocker stop unless you tell it.  Dunno if that will affect your bouncy dismount, but it's something ....

Link to comment
Share on other sites

That has to be a collision between the sitter and the physics model on standing.

Standing in SL could use an upgrade. Sitting works well, but standing too often results in standing on a chair. It's hard to do much about this from chair scripts, because they lose control on stand. But an AO feature for "graceful standing" might do it.

Someone made a chair which, when you get up, moves backwards to give the avatar some room. When there's clear space, it moves back. That could work.

Edited by animats
Clarify
Link to comment
Share on other sites

At least when I pop out of the casket I made, I end up standing on top, all cheeky-like. I don't mind it so much, myself. Perhaps having things go phantom when not sat upon could help, but I don't know.

Link to comment
Share on other sites

Thank you animats, Rolig and PheebyKatz :)

I'd like to understand more about how the chair moves back when the avatar stands up... failing to get my head around that at the moment. ETA: Thanks Rolig for posting that link!

The problem is with KFM I think...

Yes to all your questions, Rolig... seems I'm stuck... unless I make the avatar click to stop the chair rocking first before standing up. Which seems inelegant...

Standing on top would be fine PheebyKatz - unfortunately this is literally flinging the avatar around quite a distance. 

Funny to me ... I guess some people wouldn't appreciate it though ...

Link to comment
Share on other sites

Yeah, if it's throwing you at the ceiling, you might want to fix it, at least if you let company sit in it.

Alternately, you could paint it big and bright, and leave it out for people who like to sneak into people's homes and use their furniture.

  • Haha 1
Link to comment
Share on other sites

I'm not really sure how KFM works behind the scenes but the fact my mouse pointer turns into a hand when I float it over something with KFM active suggests to me that it's treating the object as if it's physical, at least while KFM is running.

That's a possible explanation for why you get thrown out of the chair -- you're within the bounding box of something that the physics engine is treating as a physical object, at least until it gets round to turning off KFM in response to a function call in the changed event.

It might be worth setting the child prims not to phantom but to PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE.   That might help, and it can't hurt to try.

Link to comment
Share on other sites

Hi Innula & PheebyKatz,

Thank you for your suggestions :).

@ Innula Zenovka - Yes I agree - it does seem like that.

I tried setting  the child prims to physics_shape NONE already - to no avail... :(

@ PheebyKatz - that might just turn it into a seller... and I wasn't even trying like I did with the Rocket Chair! HAHA

Emma :)

 

Link to comment
Share on other sites

Hi Profaitchikenz :)

Thank you for your curiosity :)

Yes it's fine without KFM running. When standing up, she stands in the chair as it's set to physics_type NONE and PHANTOM for good measure!

I tried without PHANTOM and because the seat cushion is the "engine" and can't be NONE, it pushes her nicely forward of the chair as she unsits. But there is no flinging about as happens with KFM.

Maybe I should change my mindset and call it a "feature" ... or does someone else have any ideas?

Emma :)

Link to comment
Share on other sites

I realise you want to do it with KFM, but I think we're running out of ideas!

As a workaround, when you get tired of being thrown around by KFM, here's a way to do it with llTargetOmega.     The values may need tweaking to suit your chair.  It assumes a small cube as the root prim, with its positive x axis looking the way the chair faces.    

float fArc = 6.0; //n degrees forwards or back

float fDesiredTime = 2.0; //time taken to complete a full motion, forwards and back (fArc * 2)
float fSpinRate; 

rotation rStartRot;

vector vAxis = <0.0,1.0,0.0>;
default
{
    state_entry(){
        llSitTarget(<0.0,0.0,0.25>,ZERO_ROTATION);
        fArc *= DEG_TO_RAD;//convert to radians
        vAxis.y = fArc;
        fSpinRate = (TWO_PI/fArc)/ fDesiredTime;
      //  llOwnerSay((string)fSpinRate);
    }

    changed(integer change)
    {
        if(change & CHANGED_LINK){
            if(llAvatarOnSitTarget()){
                rStartRot = llGetRot();
                llTargetOmega(vAxis*llGetRot(), 1.0, 0.1);
                llSetTimerEvent(fDesiredTime/2);
            }
            else{
                llTargetOmega(<0.0,0.0,0.0>,0.0, 0.0);
                llSetRot(rStartRot);
                llSetText("X",<1.0,1.0,1.0>,0.0);//force a redraw 
                llSetTimerEvent(0.0);
                llSetText("",<1.0,1.0,1.0>,0.0);
                             
            }
        }
    }

    timer(){
        llTargetOmega(<0.0,0.0,0.0>,0.0, 0.0);
        vAxis.y *= -1.0;
        llTargetOmega(vAxis*llGetRot(), 1.0, 0.1);        
        llSetTimerEvent(fDesiredTime);
    }
}

This is the simple dummy chair I used for testing

5b2fd287243ac_rockingchairschematic.png.213fdb7b06ad05ecd8b720c30e104c9c.png

 

Edited by Innula Zenovka
  • Like 1
Link to comment
Share on other sites

Thanks Innula - that's very kind of you.

I must have about a dozen swing scripts and I shall add yours!

Yes, I really did want to use the KFM script and was interested to explore the issue.

Now I have choice... go with the KFM script and make people stop the rocking before they get off (which is SO last decade!) or go with something like llTargetOmega...

Emma :)

Link to comment
Share on other sites

There's one more thing I'd be tempted to try.

Add a button to the menu so you can stop and start KFM.

Sit, start rocking, stop rocking. stand. (Or sit without starting rocking, then stand).

Assuming that you don't get flung around in those two situations, try tinkering with the speed of the KFM, or the pause at each end of it before you reverse the direction. You may be able to find a compromise speed that minimises the avatar disturbance and still gives acceptable rocking speed.

I've used KFM for moving vehicles (train, canal boat, funicular), and I haven't noticed the issue you are having problems with, though if a person got off any of the vehicles whilst in motion I suspect any violent movements would be masked or interpreted as a natural reaction to a stupid move).

Out of interest, I have a sign on the Mock Turtle pub that swings to and fro and is therefore using KFM in the same way as your rocking chair, and it has proved problematic, moving_end seems to trigger early or late in several instances,  and in order to stop the sign gradually working around until it is inverted, I have to reset it to the central position every twenty swings. I haven't seen any such problems with moving_end when using KFM in the vehicles going to and fro in straight lines.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

16 hours ago, Emma Krokus said:

Yes, I really did want to use the KFM script and was interested to explore the issue.

Now I have choice... go with the KFM script and make people stop the rocking before they get off (which is SO last decade!) or go with something like llTargetOmega...

Isn't llTargetOmega more efficient than KFM anyway?

If you want to play with KFM, you're always welcome to help me with any of my stalled projects Emma :D 

Link to comment
Share on other sites

Another option I was thinking about, I've seen it used in chairs. Is to use an animation that has the hip offset from the center of the avatar, and then the sit target offset in the opposite direction, so that the avatar appears centered on the target, but are actually say, 1 meter behind or in front of the object. 

  • Like 2
Link to comment
Share on other sites

Thank you Profaitchikenz, Bitsy and Ruthven :)

@ Profaitchikenz: I'll look into that. Interesting about the sign... And yes I suspect the problem with the rocking chair is getting off while it's in motion. Haha - just thought of jumping off an rl playground swing while it's swinging really high - good times :) 

@ Bitsy: Thank you, my learned friend :)  

@ Ruthven: I will look for one such animation and experiment... maybe it will throw  unseat the avatar clear of the bounding box.

Emma :) 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2127 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...