Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Walking Sound on Floor

Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
12-06-2007 21:28
So I've been a few places where people have a script that has a walking sound. It's activated when...well...you walk on it. Sounds like you're walking. Pretty neat concept.

I can make my own sounds but I'm not too savvy in the script. I know my basics but thats about it. I've looked up how to do this script and I've found some stuff about llCollisonSound, and a few other things but as per usual for me, I keep f*cking up the syntax.

Anyways, we've got snow on our land and I'd like to have it actually sound like you're walking on it.

Can anybody help me out?

EDIT::::

I've got this so far, but my problem is the sound wont stop. When I'm standing on it, it just keeps looping the sound.

string crunch_sound = "Snowstep";

default
{
state_entry()
{
llPreloadSound(crunch_sound);
llSetSoundQueueing(TRUE);
llCollisionSound(crunch_sound, 1.0);
}

collision(integer num)
{
llPlaySound(crunch_sound, 1.0);
}
}
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-06-2007 23:25
The proper approach is to get the avatars status and check if he/she/it is walking or running on a timer and then trigger the appropriate sound effects.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
12-06-2007 23:29
whats happening there is the collision event is WHILE your intersecting the object

so your choices are

collision_start(integer num_detected) for a footstep

or just

llCollisionSound only if the avatar bumps into the object (step up / down, rough landing ect) and it will be picked up by the collision_start event anyways, its really not usefull in a footsteps application
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
12-07-2007 04:04
From: Nerolus Mosienko
So I've been a few places where people have a script that has a walking sound. It's activated when...well...you walk on it. Sounds like you're walking. Pretty neat concept.

I can make my own sounds but I'm not too savvy in the script. I know my basics but thats about it. I've looked up how to do this script and I've found some stuff about llCollisonSound, and a few other things but as per usual for me, I keep f*cking up the syntax.

Anyways, we've got snow on our land and I'd like to have it actually sound like you're walking on it.

Can anybody help me out?

EDIT::::

I've got this so far, but my problem is the sound wont stop. When I'm standing on it, it just keeps looping the sound.

string crunch_sound = "Snowstep";

default
{
state_entry()
{
llPreloadSound(crunch_sound);
llSetSoundQueueing(TRUE);
llCollisionSound(crunch_sound, 1.0);
}

collision(integer num)
{
llPlaySound(crunch_sound, 1.0);
}
}

put a sleep in it so it won't repeat.

Also, perphaps get the avatars velocity, if they are standing, no sound?
_____________________
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
12-07-2007 09:13
Hmm, even with

collision_start(integer num_detected)

in place of

collision(integer num)

it still only plays the sound once.

I'm trying to make it play as footsteps, but only when the avatar is walking on it. When they are standing still, no sound.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
12-07-2007 13:02
Well... one could do this with a timer between collision_start and collision_end, but I kinda think the llSleep idea is a tiny bit less laggy. Anyway, something like this might work:

CODE

float INTER_STEP_INTERVAL = 0.35;
float SOUND_VOLUME = 1.0;
string theSound = "c3b71052-ec38-ca47-0dc1-4bd8c84667e3";

default
{
collision(integer num_detected)
{
if (AGENT_WALKING | llGetAgentInfo(llDetectedKey(0)))
{
llPlaySound(theSound, SOUND_VOLUME);
llSleep(INTER_STEP_INTERVAL);
}
}
}


Well, I don't have a snow-crunching sound (hint, hint), so this will sound like you have bells on your shoes. ;)

(Caveat: If there are multiple avatars on the same prim, some walking and some not, the _start and _end timer thing might be better. Otherwise I don't think there's a non-ghastly way to loop through the num_detected collisions to find the walking avatar that's hidden by standing-around avatars, without also continuing to process queued-up collisions after he's walked off the prim.)
Casandra Kumsung
Registered User
Join date: 6 Sep 2006
Posts: 93
Can remember where
12-07-2007 16:42
But I saw a pump for sale that had the click sound when you walked. Almost got it!
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
12-07-2007 17:29
From: Qie Niangao
Well... one could do this with a timer between collision_start and collision_end, but I kinda think the llSleep idea is a tiny bit less laggy. Anyway, something like this might work:

CODE

float INTER_STEP_INTERVAL = 0.35;
float SOUND_VOLUME = 1.0;
string theSound = "c3b71052-ec38-ca47-0dc1-4bd8c84667e3";

default
{
collision(integer num_detected)
{
if (AGENT_WALKING | llGetAgentInfo(llDetectedKey(0)))
{
llPlaySound(theSound, SOUND_VOLUME);
llSleep(INTER_STEP_INTERVAL);
}
}
}


Well, I don't have a snow-crunching sound (hint, hint), so this will sound like you have bells on your shoes. ;)

(Caveat: If there are multiple avatars on the same prim, some walking and some not, the _start and _end timer thing might be better. Otherwise I don't think there's a non-ghastly way to loop through the num_detected collisions to find the walking avatar that's hidden by standing-around avatars, without also continuing to process queued-up collisions after he's walked off the prim.)


I tried this one, it still keeps playing even after I've stood still. The intervals are a little far apart to be footsteps also. I tried changing the
"float INTER_STEP_INTERVAL = 0.35;" to no avail.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
12-07-2007 19:20
From: Nerolus Mosienko
I tried this one, it still keeps playing even after I've stood still. The intervals are a little far apart to be footsteps also. I tried changing the
"float INTER_STEP_INTERVAL = 0.35;" to no avail.
Ummm... well, for starters, I'll guess this is in a prim where llSetSoundQueueing(TRUE) was called at some point, so the sound itself is continuing to play to completion each time (limiting the effective interval to no shorter than the sound duration itself), followed by one additional queued sound after stopping walking. (There's also some delay in llGetAgentInfo, so an extra step might get played, too, which is kinda hard to avoid.)

One can also get somewhat shorter intervals using llTriggerSoundLimited than are possible with llPlaySound, and each sound will run to completion, overlapping with new sounds.

So, maybe this is better:

CODE

float INTER_STEP_INTERVAL = 0.0;
float SOUND_VOLUME = 1.0;
string theSound = "c3b71052-ec38-ca47-0dc1-4bd8c84667e3";
vector HALF_RANGE = < 8.0, 8.0, 8.0 >;
vector tne;
vector bsw;
// remember to manually reset script if prim is moved.

default
{
state_entry()
{
llSetSoundQueueing(FALSE);
vector pos = llGetPos();
tne = pos + HALF_RANGE;
bsw = pos - HALF_RANGE;
}
collision(integer num_detected)
{
if (AGENT_WALKING | llGetAgentInfo(llDetectedKey(0)))
{
llTriggerSoundLimited(theSound, SOUND_VOLUME, tne, bsw);
//llPlaySound(theSound, SOUND_VOLUME);
llSleep(INTER_STEP_INTERVAL);
}
}
}

Again, with a timer approach instead of llSleep, and lists of currently-colliding avatars and their next step times, one could use llTriggerSoundLimited to get fancy with having multiple footstep sequences running simultaneously for multiple avatars walking on the same snow prim. But because the sounds all come from the same location, I'm not sure it would be a much more compelling effect.
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
12-07-2007 23:30
Trying to figure out how to set a valid timer event...
Bid Messmer
Registered User
Join date: 13 May 2007
Posts: 13
12-13-2007 22:08
I know it's a little late to be posting here on this. but I was trying to get this effect and the if statement needs to be

if (AGENT_WALKING & llGetAgentInfo(llDetectedKey(0)))

that makes it so that it actually checks if someone is walking as apposed to if someone is detected at all.

sorry if this is resurrecting a long dead thread, but that simple change makes this work pretty well