Why won't this object destroy on collision?
Hello! I'm rather new to game development and I'm having trouble with colliders. Here's the script of the collision:
 using UnityEngine;
 using System.Collections;
 
 public class collect : MonoBehaviour {
 
     void Update ()
     {
         
     }
 
     void OnCollisionEnter(Collision col)
     {
         if(col.gameObject.name == "platform")
         {
             Destroy(gameObject);
             Debug.Log("collision detected!");
         }
     }
 }
 
               The object being destroyed is "platform". You can see its inspector here:
Why doesn't this work? Thanks in advance!
 
                 
                unity-2017-02-26-20-04-27.png 
                (32.5 kB) 
               
 
              
               Comment
              
 
               
              Answer by zachwuzhere · Feb 27, 2017 at 05:19 AM
If you are you trying to pick up an item with your player, and then destroy said item. Make sure you have a collider attached to your player, then in the inspector, give your player a tag and name it something like "player". Then change the if() statement to detect if the player collides with your platform item.
 void OnCollisionEnter(Collision col)
      {
          if(col.gameObject.tag == "player")
          {
              Debug.Log("collision detected!");
              Destroy(gameObject);
          }
      }
 
               You will also need a rigidbody attached to your player for this to work.
Your answer