コード例 #1
0
        /// <summary>
        /// play footstep sound
        /// </summary>
        /// <param name="collider">collider under character</param>
        private void _playFootstepClip(Collider collider)
        {
            FootstepsAudio fa = collider.GetComponent <FootstepsAudio>();

            if (!fa)
            {
                return;
            }
            if (footstepsUser)

            {
                for (int i = 0; i < footstepsUser.footstepsClips.Length; i++)
                {
                    AudioClip[] clips = footstepsUser.footstepsClips[i].clips;
                    int         hash  = footstepsUser.footstepsClips[i].typeHash;
                    if (fa.typeHash == hash)
                    {
                        int len = clips.Length;
                        int rnd = Random.Range(0, len);
                        m_Audio.PlayOneShot(clips[rnd]);
                        return;
                    }
                }
            }
            {
                int len = fa.FootstepClips.Length;
                int rnd = Random.Range(0, len);
                m_Audio.PlayOneShot(fa.FootstepClips[rnd]);
            }
        }
コード例 #2
0
        private FootstepsAudio ladderSounds; // sound clips that plays on ladder step

        /// <summary>
        /// initialize trigger
        /// </summary>
        public override void initialize()
        {
            base.initialize();
            ladderSounds = GetComponent <FootstepsAudio>();
        }