- Home /
Random Footsteps within CollisionSoundEffects Script
Can some one please rewrite or tell why this script for random footsteps within the collisionSoundEffects script isn't working, thanks Matt
var audioClip : AudioClip; var volumeModifier = 1.0; var soundEffectPitchRandomness = 0.05; var audioSources : AudioClip[];
function Start () { audioSources = new AudioClip[5]; }
function collisionSoundEffect.GetRandomClip(5); { var nextClip = audioSources; audio.clip = nextClip; audio.Play(); }
Answer by efge · Feb 22, 2011 at 02:39 PM
Maybe your script should look something like this:
var audioSources : AudioClip[];
function OnCollision () { var nextClip : AudioClip = audioSources[Random.Range(0, audioSources.Length -1)]; audio.clip = nextClip; audio.Play(); }
Do not forget to fill your audioSources by dragging sound files from the project folder to the inspector.
i'm experimenting on the 2d Platformer level, and what i under stand is that when the audio source that is attached to the charaters feet collides with the ground, the audio clip that is held within the ground material is sent via the CollisionSoundEffect script to the audio source attached to the feet, is this right?
The problem i'm having with the script above it that the CollisionSoundEffect script has an Audio clip already in it and it only plays that one,
Any more suggestion will be greatfuly received $$anonymous$$att
Your answer
Follow this Question
Related Questions
How do I determine which frame an animation is currently playing? 1 Answer
Footstep Audio Not Working? 1 Answer
FPS Footstep Audio Plays Too Quickly 1 Answer
Footsteps Script for Running and Walking 3 Answers
Random footsteps 5 Answers