Looking for a 'sound on contact' script? - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Looking for a 'sound on contact' script?


Scripting Discuss scripting for SL and other platforms

Reply
 
LinkBack Thread Tools Display Modes
Old 11-02-2009, 05:12 AM   #1 (permalink)
Junior Member
 
Join Date: Nov 2009
Posts: 3
Question Looking for a 'sound on contact' script?

Well i'm primarily a builder and have been for about 4 years. I make buildings and such but would like to make it so that when a person walks on the floor - a walking sound is played.

I've seen something similar on XStreet but it wasn't full perms and you couldn't even change the sound that was played.

Has anybody heard or seen of a script like this and what is it called?

Thanks
Vengeance_Ethaniel is offline   Reply With Quote
Old 11-02-2009, 06:23 AM   #2 (permalink)
Senior Member
 
Fred Rookstown's Avatar
I see what you did there.
 
Join Date: Oct 2009
Location: Internets
Posts: 114
SL Join Date: 3/16/2009
HINT: collision_start and collision_end

Also, a LOT of people find the gunshot-loudness clip-clop shoes extremely annoying. I'm sure they'll find these floors just as annoying if the noise is played at max volume. Please, for the love of God, make the sound relatively quiet.
Fred Rookstown is offline   Reply With Quote
1 User Agreed:
Old 11-02-2009, 11:38 AM   #3 (permalink)
Junior Member
 
Join Date: Nov 2009
Posts: 3
Quote:
Originally Posted by Fred Rookstown View Post
HINT: collision_start and collision_end

Also, a LOT of people find the gunshot-loudness clip-clop shoes extremely annoying. I'm sure they'll find these floors just as annoying if the noise is played at max volume. Please, for the love of God, make the sound relatively quiet.

Thanks i'll bear that in mind.

I did find a script that does it but it doesn't loop so i may just not do it after all.
Vengeance_Ethaniel is offline   Reply With Quote
Old 11-02-2009, 12:59 PM   #4 (permalink)
Free, not cheap
 
Free Xue's Avatar
Buttercup without a witty retort? Huh, imagine that!
 
Join Date: May 2009
Location: USA! USA! USA!
Posts: 1,615
My Mood:
SL Join Date: May, 2008
Business: [ Xushi ]
Blog Entries: 1
Quote:
Originally Posted by Fred Rookstown View Post
HINT: collision_start and collision_end
I've found these difficult to use with collision event detection on a floor. Since walking or standing on one behaves almost like a single, constant collision, I often see them triggered only as you hit the floor (collision_start) or leave it (collision_end).

@Vengeance

I've recently done some scripting for collision detection, avatar position and velocity/speed. Here is a snippet of that handiwork. If the sound file you use is a short clip, it should do:

Code:
string mySound = "step.wav"; // sound in prim inventory
vector agentVel; // 'avatar' velocity

default
{
    collision(integer total_number)
    {
        agentVel = llDetectedVel(0); // detect the avatar's velocity

        if( (llFabs(agentVel.x) > 1.5) || (llFabs(agentVel.y) > 1.5) )
        {
            llPlaySound(mySound, 0.5);
            llSleep(0.4);
        }
    }
}
What this does is detect the velocity/speed of an avatar (agent) during a collision event, and if it is equal to or less than 1.5 meters per second in the x or y directions, it plays the sound. 1.5mps is good cut off point I think. Walking velocity is north of 3 in any cardinal direction, and we need to make sure not to trigger the sound when turning (or fidgeting ).

The sleep is in there to cause a break in the multiple collisions occurring. I suggest playing with the duration in the llSleep() function until it fits the sound file's length best. Of course, set mySound to the name of the "walk" sound file that is in the object.
__________________

1 User Threw Up a Little In Their Mouth:
Free Xue

Last edited by Free Xue; 11-02-2009 at 01:11 PM. Reason: grammar :)
Free Xue is online now   Reply With Quote
Old 11-02-2009, 01:42 PM   #5 (permalink)
Free, not cheap
 
Free Xue's Avatar
Buttercup without a witty retort? Huh, imagine that!
 
Join Date: May 2009
Location: USA! USA! USA!
Posts: 1,615
My Mood:
SL Join Date: May, 2008
Business: [ Xushi ]
Blog Entries: 1
Just noting (based on this thread and another from Vengeance) that SLUniverse has a Scripting sub-forum under Development Discussion that would be a better place to post your script-related queries.

(was moved )

Last edited by Free Xue; 11-02-2009 at 02:03 PM. Reason: thread was moved
Free Xue is online now   Reply With Quote
Old 11-02-2009, 05:06 PM   #6 (permalink)
Senior Member
 
Fred Rookstown's Avatar
I see what you did there.
 
Join Date: Oct 2009
Location: Internets
Posts: 114
SL Join Date: 3/16/2009
SL physics does not register the individual steps you take on a surface. Your avatar is basically enclosed in a box, so when you're walking over a surface, you're basically dragging the bottom of that box across the surface, producing a long collision event.

Some psuedocode for you that may help:

On Collision_Start,
Start Timer Event
end Collision_Start Event

On Timer event,
Play foot impact sound
End timer Event

On Collision_End event,
Stop timer
End Collision_End event
Fred Rookstown is offline   Reply With Quote
Old 11-02-2009, 05:16 PM   #7 (permalink)
Member
 
Innula Zenovka's Avatar
Rather more than just a pretty face
 
Join Date: May 2009
Posts: 34
My Mood:
SL Join Date: 17 June 2007
Gwyneth Llwellyn has an alternative approach to heel-sounds, which is worth considering Gwyn’s Home » Blog Archive » Heel sounds on your shoes
Innula Zenovka is offline   Reply With Quote
Old 11-02-2009, 07:21 PM   #8 (permalink)
Free, not cheap
 
Free Xue's Avatar
Buttercup without a witty retort? Huh, imagine that!
 
Join Date: May 2009
Location: USA! USA! USA!
Posts: 1,615
My Mood:
SL Join Date: May, 2008
Business: [ Xushi ]
Blog Entries: 1
Quote:
Originally Posted by Fred Rookstown View Post
SL physics does not register the individual steps you take on a surface. Your avatar is basically enclosed in a box, so when you're walking over a surface, you're basically dragging the bottom of that box across the surface, producing a long collision event.
If true, it doesn't work quite as it should (or the way I imagine most think it would). Adding this to a floor:

Code:
default
{
    collision(integer total_number)
    {
        llSay(0, (string)llDetectedVel(0));
    }
}
...can generate a single chat line, but more often than not multiple or even a constant stream of lines when the agent mere stands on it (velocity is 0).

Your pseudo-code in actual code:

Code:
string mySound = "step.wav"; // collision sound

default
{
    collision_start(integer total_number)
    {
        llSetTimerEvent(0.5);
    }

    timer()
    {
        llPlaySound(mySound, 0.50);
    }
    
    collision_end(integer total_number)
    {
        llSetTimerEvent(0.0);
    }
}
...works, but several additional collision_start events are often generated as the agent comes to a halt on the floor prim. In any case, rotations would still need to be weeded out.

Quote:
Originally Posted by Innula Zenovka View Post
Gwyneth Llwellyn has an alternative approach to heel-sounds, which is worth considering Gwyn’s Home » Blog Archive » Heel sounds on your shoes
Testing on the llGetAgentInfo() AGENT_WALKING constant does provide a nice alternative to checking velocity. Here's a quick script based on it:

Code:
string mySound = "step.wav"; // collision sound
key ID; // agent ID key;

default
{
    collision(integer total_number)
    {
        ID = llDetectedKey(0);
    
        if ( llGetAgentInfo(ID) & AGENT_WALKING )
            llPlaySound(mySound, 0.5);

        llSleep(0.5);
    }
}
Free Xue is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On