Sign in to follow this  
mbmusicpl

PlayAudio Script

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thank You Guys!!!
I also found a way to use FMOD here, maybe it will be helpfull for someone:
Tutorial:
https://www.youtube.com/watch?v=qN5lj9QT6Ws

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 () {
 
}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this