Search Unity

i can't add an array of colliders to my trigger

Discussion in 'Scripting' started by brunoenvia, Nov 22, 2019.

  1. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    52
    if i try to add an array of colliders to my trigger by object will get killed by anything
    that has a trigger. how can i solve this?

    Code (CSharp):
    1. SceneLoader sceneLoader;
    2.     public bool isPlayerDead = false;
    3.     [SerializeField] Collider[] deathCollider = new Collider[2];  
    4.     [SerializeField] GameObject ball;
    5.     [SerializeField] ParticleSystem deathVFX;  
    6.     [SerializeField] AudioClip deathSFX;
    7.     [SerializeField] AudioSource audioSource;
    8.  
    9.     private void Awake()
    10.     {
    11.            
    12.     }
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         sceneLoader = FindObjectOfType<SceneLoader>();
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.        
    24.     }
    25.  
    26.      public void OnTriggerEnter(Collider deathCollider)
    27.     {    
    28.            PlayerDieing();      
    29.     }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    7,811
    Your question is difficult to understand. Are you complaining that anything that enters the trigger is causing the player to die? If so, check in OnTriggerEnter for only specific things which you want to cause it to die. Checking the tag of the object which entered the trigger is a typical approach, as is checking for a specific component attached.
     
unityunity