Trouble changing sound when going through a collider.
I'm not great with coding so go easy on me. I have a script on my character that controls the movement and also plays the footstep sound. I want to change this sound when the player goes through 'portals' (so basically when the player hits a collider). The movement script is called 'physicWalk' and the variable is called 'footstepSound'.
I've tried making a really simple script that will change the variable on collision but i'm getting the error: An object reference is required to access a non static member. This is what I have so far
public class FootstepSelector : MonoBehaviour
{
public AudioClip FSound;
void OnCollisionEnter()
{
physicWalk.footstepSound.LoadAudioData (FSound);
}
}
As you can see I want to be able to load different sounds as there are many different colliders leading to different surfaces.
Thanks in advance
Answer by Greenacid · Jul 24, 2018 at 11:25 PM
I'm no expert but i think you want to change the audio clip on the audio source, not just the clip. I hope this helps.