Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

freebie kiss/hug, or av "move to" code?

Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-29-2007 10:57
Hi, I'm coding up a freebie mistletoe to be worn. I have everything I need (I think), except the scripts.

Anyone know of freebie (and modifiable) kiss/hug attachment script? Having that to start with would save me a lot of hassle.

If not, does anyone have a snippet of code that, given the vector of the other av, points and moves the wearer to the other av? What's the best approach -- working like WarpPos()?

Thanks!
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-29-2007 12:02
From: Lear Cale
Hi, I'm coding up a freebie mistletoe to be worn. I have everything I need (I think), except the scripts.

Anyone know of freebie (and modifiable) kiss/hug attachment script? Having that to start with would save me a lot of hassle.

If not, does anyone have a snippet of code that, given the vector of the other av, points and moves the wearer to the other av? What's the best approach -- working like WarpPos()?

Thanks!

You could check bounding boxes to determine how close to put them, or just have them walk right up to the target's position, but I would use llMoveToTarget with a tau of 0.5.

If you want to make it so that it stops in front of the target without shoving them, you could make your destination vector like this:

vector destination = (target's position) - distance * llVecNorm(target's position - wearer's position);

Where distance is a float that determines how far away, in meters, your avatar's center wants to be from theirs. Small distances will end up pushing your target a little as it tries to move onto their exact center; I don't know offhand what the horizontal size of avatar bounding boxes generally is.

More specifically, you can probably do this to make it exact, although I haven't tried it:

vector hugged = llList2Vector(llGetBoundingBox(target's key), 1);
vector wearer = llList2Vector(llGetBoundingBox(wearer's key), 1);

vector destination = (target's position) - llVecMag(<hugged.x + wearer.x, hugged.y + wearer.y, 0.0>;) * llVecNorm(target's position - wearer's position);
_____________________
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-29-2007 12:29
Thanks, Tyken Hightower, that helps! And I suppose I use llLookAt() to point the av.
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
11-29-2007 12:43
From: Lear Cale
Thanks, Tyken Hightower, that helps! And I suppose I use llLookAt() to point the av.


Sadly that doesn't work. There is no current way to turn an AV. I surely wish there was.
_____________________
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-29-2007 13:37
Thanks for helping me to avoid wasting time, Darien!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-29-2007 23:33
search inworld for 'multi-tool' hug kiss attachment... the complete code is in there, here's the snippet from the movement part that I was reworking at one point...

CODE

vector pos;
//-- note for Lear: this could be fed from a sensor & llDetectedPos
avPos = llList2vector( vgLstTargetData, 1 ); //--tweaked

//-- why are we doing this 3peat dance? why do we need rotation?
pos = avPos + <0.3, 0, 0> * ZERO_ROTATION; //-- can we get other avs rot from sensor?
llMoveToTarget( pos, .5 );
llSleep(.6);
pos = avPos + <0, 0, 0> * ZERO_ROTATION; //-- can we get other avs rot from sensor?
llMoveToTarget( pos, .5 );
llSleep(.6);
llMoveToTarget( pos, 1 );
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
11-30-2007 12:45
From: Void Singer
search inworld for 'multi-tool' hug kiss attachment... the complete code is in there, here's the snippet from the movement part that I was reworking at one point...

CODE

vector pos;
//-- note for Lear: this could be fed from a sensor & llDetectedPos
avPos = llList2vector( vgLstTargetData, 1 ); //--tweaked

//-- why are we doing this 3peat dance? why do we need rotation?
pos = avPos + <0.3, 0, 0> * ZERO_ROTATION; //-- can we get other avs rot from sensor?
llMoveToTarget( pos, .5 );
llSleep(.6);
pos = avPos + <0, 0, 0> * ZERO_ROTATION; //-- can we get other avs rot from sensor?
llMoveToTarget( pos, .5 );
llSleep(.6);
llMoveToTarget( pos, 1 );


To answer your question in the comments, as to why 3 times, I discovered it's in order to dampen the movement so that if the person being moved is far away, they don't come crashing into the person that is stationary :) You get quick movement to the position .3 meters away from the other AV, then drawn in slowly, and then push a bit harder in case they struggle and try to escape the hug. :p
_____________________
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-30-2007 18:20
Thanks folks! I have it working except that the anims I have (from free kiss balls, where the girl's foot goes up) don't quite get close enough together. I'd need anims where the anim position is about 5 cm forward of the anim's position. But, such as it is, it's still fun.

I'll soon be posting a spot where anyone who's interested can pick one up, and I'll deliver them to anyone who's posted.

I used Tyken's method to move close to the other av without bumping them (much). I also added a little feature that I think more kiss/huggers should have: the ability to quit early and to move the wearer's av up and down. (Unfortunately, not down below where their feet hit the ground, so it can't correct all height difference problems. If anyone knows a solution to this, like making the av phantom ... hmmm ... Lear's gears begin to spin ...)

Thanks again, big help!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-30-2007 22:19
From: Darien Caldwell
To answer your question in the comments, as to why 3 times, I discovered it's in order to dampen the movement so that if the person being moved is far away, they don't come crashing into the person that is stationary :) You get quick movement to the position .3 meters away from the other AV, then drawn in slowly, and then push a bit harder in case they struggle and try to escape the hug. :p


thanks Darien good catch, I had figured that out, but never applied it to that version (which is on the HD) and simplified it to 2 moves, but it is good to know.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -