Hi guys and girls…
Just thought I would post this for you, its a simple footsteps script I’ve been using for years works in all games I have developed… just make slight adjustments to the script to make the sound work perfectly…
So heres the script enjoy!!
using UnityEngine;
using System.Collections;
public class Footsteps : MonoBehaviour {
public AudioClip audioFootsteps;
private Vector3 prevPosition;
float minDistance = 2.4f;
void Start()
{
prevPosition = transform.position;
}
void Update()
{
if (Vector3.Distance(transform.position, prevPosition) > minDistance)
{
AudioSource.PlayClipAtPoint(audioFootsteps, transform.position);
prevPosition = transform.position;
}
}
}