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;
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
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
6 People are following this question.
Audio Endless Loop c#
OnTriggerEnter Footsteps Multiple Times A Second
Audio Source does not contain definition for any of the Play functions...
How to stop a sound playing once another starts? (C#)
Soundarray for player is not working properly