PlayAudio Script

Started by
2 comments, last by mbmusicpl 7 years ago

Hi,
I am sound designer not programmer and i need Yor help. I am adding footsteps to 3rd person character.
I made simple script in Java and put it into animation events as function. It works very well.
http://imgur.com/a/JDIPV

What i need is someone to help me with adding “random pitch function” to my script.

Also is there a tut how to do it with FMOD? Viking Villiage shows only 1st person character

Advertisement

Not sure if this will help you but you can try to use/adapt my old script for Footsteps in C#

http://grogon.com/footsteps-sounds-in-unity3d-c-code-example/

♫♪♩♫ sound effects ♦ music ♦ for games ♫♪♩♫

You can set the AudioSource's .pitch value to get randomization. A value of 1.0 means "default" pitch; a value of 0.5 will lower it by one octave; a value of 2.0 will increase the pitch by 1 octave.

So just select a random number for your pitch (setting the low and high range according to how much variation you want) and set the do

pitchval = Random.Range(low,high);

Audiosource.pitch = pitchval;

Also..on a side note, using GetComponent every time you want to access the component's AudioSource is very inefficient. Instead, in the Start() routine, call GetComponent<AudioSource> and save it to a private variable inside your class. Then use that variable to access the AudioSource.

Brian Schmidt

Executive Director, GameSoundCon:

GameSoundCon 2016:September 27-28, Los Angeles, CA

Founder, Brian Schmidt Studios, LLC

Music Composition & Sound Design

Audio Technology Consultant

Thank You Guys!!!
I also found a way to use FMOD here, maybe it will be helpfull for someone:
Tutorial:

Function that allow to use fmod event in "Animation events"

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Footsteps : MonoBehaviour {
// Use this for initialization
void PlaySound(string path)
{
FMODUnity.RuntimeManager.PlayOneShot(path, GetComponent<Transform> ().position);
}
// Update is called once per frame
void Update () {
}
}

This topic is closed to new replies.

Advertisement