Sound on movement
|
|
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
|
10-07-2006 19:58
Ok, I am looking to make the fuction that some collars have in them where they will jingle as a person moves around. I have been playing with this, but am having some issues, if anyone has done this before or has a tested solution, I would appreciate it.
Here are what I have tried and the problems:
moving_start event is set off when an anim moves so much as a hair... this leads to a constant sound
using the timer seems to be the best option at this point, having it check location every second or so, then if the distance is over an amount, play sound. I just want to make sure this is sensative enough to catch the person when they move a short bit (maybe 0.5).
I guess what I am looking for, is if there is a trick or something I am just completely overlooking. Thanks.
|
|
Gaius Goodliffe
Dreamsmith
Join date: 15 Jan 2006
Posts: 116
|
10-08-2006 13:05
I would definitely use moving_start. This only leads to constant sound if, for some reason, you decide to play sound every single time you receive the event, rather than something like only when you haven't played the sound in some amount of time or based on how much they've moved since the last time you played it or whatever criteria you prefer.
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
10-08-2006 14:48
I would suggest you look at an Animation Overrider script. Those trigger animations when specific conditions are matched. Use the same to trigger/loop and stop your sounds.
|
|
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
|
10-08-2006 16:04
moving_start will trigger when you are just standing there if you have the item attached. Try it out and you will see what I mean. I had thought about just looking for the movement state like you suggest Squirrel. I will give it a try
|
|
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
|
10-08-2006 16:43
moving_start/end is bugged when used in an attached object and do not trigger properly there are other ways, but i will just point you to the wiki since it is fairly trivial http://rpgstats.com/wiki/index.php?title=Main_Page
_____________________
 tired of XStreetSL? try those! apez http://tinyurl.com/yfm9d5b metalife http://tinyurl.com/yzm3yvw metaverse exchange http://tinyurl.com/yzh7j4a slapt http://tinyurl.com/yfqah9u
|
|
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
|
10-08-2006 17:39
I have been coding for quite a while and I am well aware of the wilki. I know that its bugged, I was wondering if anyone had any tested methods that worked well.
This is far from my first script, but rather than chase around this looking for the least buggy solution, I figured I would see if anyone already had gone through it.
|
|
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
|
10-08-2006 19:23
Animation overrider was a good hint. I too would use a 1 sec timer to check if (llGetAnimation(llGetOwner()) != "Standing"  or != "Sitting" / "Sitting on Ground", with an additional check if it changes from sitting to standing or the other way round.
|
|
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
|
10-09-2006 03:22
i use a script ive mod it for walking and swimming, this is the orignal script for flying: default { state_entry() { llSetTimerEvent( 2 ) ; }
timer() { if( (llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && !isFlying ) { //call sound or particle here isFlying = TRUE; }
else if( !(llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && isFlying ) { //stop sound or particle here isFlying = FALSE; } } } -LW
|
|
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
|
10-09-2006 21:51
Awesome, just what I was looking for; simple and efficient. Thanks Lightwave.
|
|
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
|
10-10-2006 18:33
A similar technique would be to use a timer to check llVecMag(llGetVel()) > some_threshold_value, then from there triggering the sound. You could even scale the volume based on velocity.
|
|
Krimson Gray
Registered User
Join date: 5 Dec 2006
Posts: 40
|
04-08-2007 00:08
I had to change this a bit to get it to work. Added one line actually. The first one. integer isFlying;
default { state_entry() { llSetTimerEvent( 2 ) ; }
timer() { if( (llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && !isFlying ) { //call sound or particle here isFlying = TRUE; }
else if( !(llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && isFlying ) { //stop sound or particle here isFlying = FALSE; } } }
|
|
Dan Colville
Registered User
Join date: 28 Jul 2006
Posts: 26
|
09-21-2008 03:57
From: Krimson Gray I had to change this a bit to get it to work. Added one line actually. The first one. integer isFlying;
default { state_entry() { llSetTimerEvent( 2 ) ; }
timer() { if( (llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && !isFlying ) { //call sound or particle here isFlying = TRUE; }
else if( !(llGetAgentInfo( llGetOwner() ) & AGENT_FLYING) && isFlying ) { //stop sound or particle here isFlying = FALSE; } } } Hay guys i'm really nooby so can someone fill in where it says //call sound and //stop sound for me
|
|
Seshat Czeret
Registered User
Join date: 26 May 2008
Posts: 152
|
09-21-2008 04:18
From: Dan Colville Hay guys i'm really nooby so can someone fill in where it says //call sound and //stop sound for me http://lslwiki.net/lslwiki/wakka.php?wakka=soundYou're looking for llPlaySound() and llStopSound(), both of which are on that page.
_____________________
My blog: http://seshat-czeret.blogspot.com/ My shop: http://slurl.com/secondlife/Achlya/199/185/102
|
|
Dan Colville
Registered User
Join date: 28 Jul 2006
Posts: 26
|
09-21-2008 04:31
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-21-2008 06:19
not sure where i found this VERY simply script, but it works, jut implement whatever you need to into the not at target function. i do remember that whoever made it said they used it as a work around for moving and moving end for an attachment From: someone default { state_entry(){ //define current avatar/prim position here llTarget(llGetPos(), 1.0); } not_at_target(){ //Moved llOwnerSay("Moved"  ; llTarget(llGetPos(), 1.0); } } edit: and i'm pretty sure it's not laggy right? no timers or sensors cehcking if the avatar is moving
|
|
Dan Colville
Registered User
Join date: 28 Jul 2006
Posts: 26
|
09-22-2008 05:14
O
|