- Home /
Audio on collision is not playing
Hello i have an FPController player and a Capsule. I put this script on the capsule:  using System.Collections; using System.Collections.Generic; using UnityEngine;
 using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Collision : MonoBehaviour { public AudioSource tick;
 // Use this for initialization
 void Start () {
     tick = GetComponent<AudioSource>();
 }
 
 // Update is called once per frame
 void Update () {
     
 }
  void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.gameObject.tag == "FPController")
     { tick.Play(); }
 }
}
I basicly want the sound to be played when the FPController enters the collision with capsule... What have i done wrong?The sound is not playing when player is colliding with it... 
Answer by CaffeineAndCoffee · Aug 08, 2017 at 02:42 PM
In your script, you are checking to see if the object hit has a "FPController" tag. The player has a "Player" tag. 
 
 Change this: 
 
if (collision.gameObject.tag == "FPController")if (collision.gameObject.tag == "Player")Or you can just check for the name:
if (collision.gameObject.name == "FPController")Your answer
 
 
             Follow this Question
Related Questions
Change Pitch on Collision 1 Answer
Getting audio to play on collision 3 Answers
Sound on collision 3 Answers
My first script, and I need some help. 1 Answer
Can not play a disabled audio source 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                