- Home /
Different Surface Footstep Sounds Whilst using W and E keys for footstep input
Hi, My current setup in my level is for the player to use either the W or E keys for forward input. I currently have two scripts one for the Left Foot (W Key) and one for the right foot (E Key) Which basically say if the key is pressed then play an audio clip. I then have my player object set-up in a hierarchy with the main camera parenting a game object. The game object contains an audio source and the left and right footstep scripts when pressing W or E keys. The reasoning for this setup is because I am using Kinect with this.
My question is how do I get the Left and Right footstep keys to play different sounds in different areas? At the moment they have only one audio attached to each script. How would I make it so I can change the audio clip these play in different trigger areas e.g. if you want a section to sound like shallow water play a splashing footstep on either script?
Quite new with Unity so detailed explanations would be magnificent!
Answer by snagglepuss · Jan 08, 2012 at 07:07 PM
I would use tags to trigger different sounds for your footsteps in different triggerzones. I can give you a more detailed explanation if needed.
Answer by andaleeni · Feb 21, 2012 at 12:11 PM
I got around this problem using the lerpz tutorial to a degree, so I made a foot object as a spherical rigid body collider, animated it to go up and down to simulate a footstep then used the lerpz script on the foot to say if foot collides with floor then playback the sound located on the floor. The surfaces are all assigned a soundclip which return on collision with foot object. I also made a feel script using the same method virtually allowing players to feel a wall.