- Home /
Audio source playing different soundfiles
Hello guys,
I am having a rather wierd problem, i am trying to make a FPS in Unity right now and i stumbled over something strange while trying to implement an audiosource which is supposed to play when i shoot a weapon. I have my Player prefab which makes use of the standart Unity FPS Movement script which already contains some sounds (running, landing etc.) and those are working fine. As i said now i am trying to add another sound that gets played when i shoot. This sound is supposed to be played from a Shootingscript;
public AudioSource gunsound;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
gunsound.Stop();
gunsound.Play();
Debug.Log("Shoot!");
At this point there is this Script and the linked audio source with the gunsound in the player prefab. Now comes the weird part, when i test it out, using leftclick doesnt make the gunsound, but it repeats the last sound the Player prefab made, e.g. when i walk and make a sound, leftclicking plays that sound, when i land after jumping, leftclicking makes the landingsound etc. Right now i have no idea on what to do anymore.
Your answer
Follow this Question
Related Questions
Play sound from an array, not random, and only once 3 Answers
AudioSource pitch measurement unit 1 Answer
Using Distance from AudioSource 0 Answers
Random, 3d sound. 1 Answer
[NoBraves] Sound makes lag 1 Answer