Audio Bug? In case of Colliders

Hey Unity Community,

I am a step away to throw my laptop out of the window. :smile:

I created a GameObject which get destroys after the Player Character collide with it. This works totally fine, the particleEffects and everything is fine. As long as I dont try to add sounds. As soon I add a AudioSource and a Clip to hit, the Player is moving this GameObject around and it does not destroy itself anymore. Just nothing… down below the working and non working (added audio) version of the same script. Maybe you have a idea. :frowning:

Working:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CollectBooks : MonoBehaviour {

    public GameObject particleEffect;

    Combat player;

    // For initialization
    void Start() {
        player.GetComponent<Combat> ();
    }

    // Update is called once per frame
    void Update () {
        // Infinity Rotation
        transform.Rotate(Vector3.up, 100 * Time.deltaTime);

    }

    void OnCollisionEnter (Collision other) {
        if (other.gameObject.tag == "Player") {
            Instantiate (Resources.Load (particleEffect.name), transform.position, Quaternion.identity);
            Combat.currentXP = Combat.currentXP + 50f;
            Destroy (gameObject);
        }
    }
}

Non working version:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CollectBooks : MonoBehaviour {

    public GameObject particleEffect;
    public AudioClip collectSound;

    private AudioSource source;

    Combat player;

    // For initialization
    void Start() {
        player.GetComponent<Combat> ();
        source = GetComponent<AudioSource> ();
    }

    // Update is called once per frame
    void Update () {
        // Infinity Rotation
        transform.Rotate(Vector3.up, 100 * Time.deltaTime);

    }

    void OnCollisionEnter (Collision other) {
        if (other.gameObject.tag == "Player") {
            source.PlayOneShot (collectSound, 1f);
            Instantiate (Resources.Load (particleEffect.name), transform.position, Quaternion.identity);
            Combat.currentXP = Combat.currentXP + 50f;
            Destroy (gameObject);
        }
    }
}

Are you sure you didn’t do anything else? Like change the tag, or change your collider to a trigger, or something? Adding sounds wouldn’t change any collision functionality, so you had to have accidentally done something else.