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;

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…

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")

To this:

if (collision.gameObject.tag == "Player")

Or you can just check for the name:

if (collision.gameObject.name == "FPController")