Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

PlayAudio Script

4: Adsense
  • You cannot reply to this topic
3 replies to this topic

#1 mbmusicpl   Members   

117
Like
0Likes
Like

Posted 07 April 2017 - 02:23 AM

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



#2 no9   Members   

284
Like
1Likes
Like

Posted 09 April 2017 - 05:51 AM

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 ♫♪♩♫


#3 bschmidt1962   Members   

2295
Like
1Likes
Like

Posted 17 April 2017 - 11:21 AM

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


#4 mbmusicpl   Members   

117
Like
0Likes
Like

Posted 20 April 2017 - 11:33 AM

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