Jump to content
  • Advertisement
Sign in to follow this  

PlayAudio Script

This topic is 520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

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:

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!