Jump to content

Newbie: Animate an attached Prim


vh1 Boa
 Share

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

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

Recommended Posts

Hi,

i have a Prim attached on Avatar's Pelvis.

Now i want to animate it 'on touch' to come out like a tongue.

My version:

 


vector startPosition;
vector endPosition;
integer counti = 0;

default {
    
    on_rez(integer a) {
      llResetScript();
    }
    
    
    state_entry()    {
        startPosition =  llGetPos();
        endPosition = startPosition + <0.0,0.0,0.1>;
    }

    touch_start(integer total_number) {
        if (counti==0) {
            llOwnerSay( "Up");
            counti = 1;
             llSetPrimitiveParams([PRIM_POSITION,endPosition]);
        } else {
            llOwnerSay( "Down");
            counti = 0;
            llSetPrimitiveParams([PRIM_POSITION,startPosition]);
        }
    }


 

It works fine if i rez it on Ground, but not as attachment.

So, whats the Problem?

Thank you

VH1

 

 

Link to comment
Share on other sites

This should work for an attachment:

 

vector startPosition;vector endPosition;integer counti = 0;default {        on_rez(integer a) {      llResetScript();    }            state_entry()    {        startPosition =  llGetLocalPos();        endPosition = startPosition + <0.0,0.0,0.1>;    }    touch_start(integer total_number) {        if (counti==0) {             llOwnerSay( "Up");            counti = 1;             llSetPos(endPosition);        } else {             llOwnerSay( "Down");            counti = 0;            llSetPos(startPosition);        }    }}  

 

 

Link to comment
Share on other sites

you need to reset it when it attaches =)

although my test with the same code showed something ridiculous... I had to make moves of 1.4m or more before the viewer would show it to me on V2... adding llSetText at the end of the touch cured it, but that shouldn't be happening (and it's not your code at fault)

Link to comment
Share on other sites

Hi,

reset if attach seems to work for the "dissapearing".

But now happens: Nothing!

my code so far:

 

vector startPosition;vector endPosition;integer counti = 0;default {        on_rez(integer a) {      llResetScript();    }         attach(key id)    {              llResetScript();    }    state_entry()    {        startPosition =  llGetLocalPos();        endPosition = startPosition + <0.1,0.0,0.05>;    }    touch_start(integer total_number) {        if (counti==0) {             llOwnerSay( "Up");            counti = 1;            llSetPos( endPosition );          } else {             llOwnerSay( "Down");            counti = 0;            llSetPos( startPosition );          }    }}

 

 

I tried also

llSetPrimitiveParams([PRIM_POSITION,endPosition])

and

llMoveToTarget(endPosition,0.5)

Nothing works.

I hope theres a way to move this thing...

Thank you,

 

VH1

P.S.: ... dont work with <2,2,2> distance ...

Link to comment
Share on other sites

Have you tried Voids llSetText trick?

 

vector startPosition;vector endPosition;integer counti = 0;default {        on_rez(integer a) {      llResetScript();    }         attach(key id)    {              llResetScript();    }    state_entry()    {        startPosition =  llGetLocalPos();        endPosition = startPosition + <0.1,0.0,0.1>;    }    touch_start(integer total_number) {        if (counti==0) {             llOwnerSay( "Up");            counti = 1;            llSetPos( endPosition );             llSetText(" ", <1,1,1>, 0);         } else {             llOwnerSay( "Down");            counti = 0;            llSetPos( startPosition );              llSetText("  ", <1,1,1>, 0);         }    }}

 

This works great for me.

 

Link to comment
Share on other sites

llSetText may be too gentle to work all the time.  I sometimes have better luck changing the color of a prim face.  Try this version, which recolors face #1 .......

 

vector startPosition;vector endPosition;integer counti = 0;default {        attach(key a) {        if(a)        {          llResetScript();        }    }            state_entry()    {        startPosition =  llGetLocalPos();        endPosition = startPosition + <0.0,0.0,0.1>;    }    touch_start(integer total_number) {        llSetPos((vector)llList2String([startPosition,endPosition],counti= !counti));        llOwnerSay(llList2String(["In","Out"],counti));        llSetColor(<1.0,1.0,1.0>*counti,1);    }}  

 

 

Link to comment
Share on other sites

yay an optimized version...

...and now to make everything relative, and not reset when in the up position:

integer gBooMoved;default {    touch_start( integer total_number ) {        llSetPos( llGetLocalPos() + llList2Vector( [<0.0, 0.0, -0.1>, <0.0, 0.0, 0.1>], (gBooMoved = !gBooMoved) ) );        llOwnerSay( llList2String( ["Down","Up"], gBooMoved ) );        llSetText( (string)gBooMoved, ZERO_VECTOR, 0.0 );        //llSetColor( <1.0,1.0,1.0> * gBooMoved,1 ); //--fails to show the first move if color is already white    }}

 

 

Link to comment
Share on other sites

Hi,

yes, works great!

Thank you!

But: Little problem again:

If i set my Prim "Down" and detach it, this place is the new start place!

So it must return to the startPosition befor i take it of.

Is there an event BEFORE detach of a Prim?

i tried:

 

     attach(key id) {              if(id) {            llResetScript();        } else {             llSetPos( startPosition );              llSetText(" ", <1,1,1>, 0);          }

 without success.

 

Thank you

 

VH1

 

Link to comment
Share on other sites

sure, add an attach event like in rolig's example, but instead of  a reset, check if gBooMoved is true and if it is call the same move code... at that point you might want to shift the move code to it's own function that you can call

it works because the prim no longer cares where it's at in the moment, it just moves up or down from where it's located at the moment.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...