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

how keep track of game objects positions when they collide with trigger!

Discussion in '2D' started by Eiyon, May 30, 2015.

  1. Eiyon

    Eiyon

    Joined:
    Apr 23, 2015
    Posts:
    5
    Hi Every one.
    I want to keep the positions of the enemy(s) that collide with my target collier.
    the target should be able to store up to 8 target.
    so I'll appropriate any suggestion, advise or piece of code!
    thank you all!!! t.jpg
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,852
    Hi Eiyon.

    Look into OnCollisionEnter. This will give you the colliding object, then just record the information you need and put it into a list.
     
    Eiyon likes this.
  3. Eiyon

    Eiyon

    Joined:
    Apr 23, 2015
    Posts:
    5
    yes thank you. i did almost the exact thing, since target was a trigger I put it OnTriggerEnter.