- Home /
Question by
jacobgeschwentner · Nov 30, 2020 at 08:15 PM ·
gameplay
How do I implement stepping sounds in top down my code isn't working?
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Footstep : MonoBehaviour {
PlayerMovement pm;
private bool grounded;
// Start is called before the first frame update
void Start()
{
pm = GetComponent<PlayerMovement>();
grounded = true;
}
// Update is called once per frame
void Update()
{
if(pm.grounded == true && pm.velocity.magnitude > 2f && GetComponent<AudioSource>().isPlaying == false)
{
GetComponent<AudioSource>().Play();
}
}
}
Comment
Where is the Footstep script applied to? Does your source have an audio clip? Does your camera have an audio listener?
Your answer
![](https://koobas.hobune.stream/wayback/20220613020838im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NEED HELP!!! 0 Answers
Import a 3D model in Game (during runtime in GUI) 3 Answers
Using GIMP with Unity 1 Answer
How to make stack of objects to move where bottom moves earlier than the top and stack looks natural 0 Answers
Memory leak issue 3 Answers