My player has a rigidbody fps controller from standard assets. I don’t have any animations or character. How can i add footsteps? I tried something like this. This doesn’t work properly.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FootStepController : MonoBehaviour
{
//config params
[SerializeField] GameObject Player;
//params
AudioSource audioSource;
// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
if (Player.GetComponent<Rigidbody>().velocity.magnitude > Mathf.Epsilon)
{
audioSource.Play();
}
else if (Player.GetComponent<Rigidbody>().velocity.magnitude == Mathf.Epsilon)
{
audioSource.Stop();
}
}
}