Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Destroy Model with trigger to working

Discussion in 'Scripting' started by fredyyanez, Jun 4, 2015.

  1. fredyyanez

    fredyyanez

    Joined:
    Jul 8, 2014
    Posts:
    33
    I'm using the oculus FPS character control along with a character collider. I have a paths of arrows that i want to disappear as soon as the character goes through them. I imported an arrow ( type FBX) file, i added a collider script that that destroys itself onTriggerEnter. For some reason it doesn't seem to work. I replaced the arrow with a regular cube and that work. Can some one please tell me what is going on? The object is called arrow and it has a child called mesh1. I have attached the inspector properties for both. Thanks!!

    My code is the following:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Arrow : MonoBehaviour {
    5.  
    6.  
    7.     void OnTriggerEnter( Collider other){
    8.  
    9.         Debug.Log ("it works");
    10.         Destroy (gameObject);
    11.  
    12.         }
    13.  
    14.  
    15.  
    16. }
    17.  
     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    Mesh colliders are tricky — you've claimed it is convex, but it's an arrow shape, so probably not convex. I don't know if that's the problem, but it well might be.

    For this application, I would think that a box or sphere collider would be fine, and more reliable.
     
  3. fredyyanez

    fredyyanez

    Joined:
    Jul 8, 2014
    Posts:
    33
    That was exactly the problem. I switched it to a box collider yesterday and it worked fine.

    Thanks!