So I am building a scene for my VR project, and I want to play footsteps sound whenever my character is moving. I thought this might be a piece of cake, but for some reason I cannot access the AudioSource class in the code for the chraracter movement.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] Transform playerCamera = null;
[SerializeField] float mouseSensitivity = 10f;
[SerializeField] bool lockCursor = true;
AudioSource audioSrc;
bool isMoving = false;
public CharacterController contoller;
public float speed = 6f;
float cameraAngle = 0f;
// Start is called at the start
void Start(){
if(lockCursor){
// locks cursor to middle of the screen
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
audioSrc = GetComponent<AudioSource>();
}
}