Search Unity

How to check all the gameobjects inside a circle collider 2D trigger?

Discussion in 'Scripting' started by Pixitales, Jun 10, 2019.

  1. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    227
    I want to get all the gameobjects who is inside the circle collider and give them health. It totally doesn't work at all, not even the debug.log work. My Player works though. I am just hard coding everything right now.

    This collider is a spell. Once is activated, this turns on:


    private void OnTriggerEnter2D(Collider2D collision)
    Code (CSharp):
    1.     private void OnTriggerEnter2D(Collider2D collision)
    2.     {
    3.         if (collision.CompareTag("Ally"))
    4.         {
    5.             Character c = collision.GetComponentInParent<Character>();
    6.             c.Healing(50, source);
    7.  
    8.             Debug.Log("hit");
    9.         }
    10.     }
     
    Last edited: Jun 10, 2019
  2. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    227
    actually i got it to work with triggerstay