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

OnTriggerStay2D Updating

Discussion in '2D' started by Iblotn, Apr 27, 2015.

  1. Iblotn

    Iblotn

    Joined:
    Mar 13, 2015
    Posts:
    4
    i have a problem with OnTriggerStay2D

    void OnTriggerStay2D(Collider2D other) {

    if (other.transform.position.x == 0.0f) {
    if(other.transform.position.y != 0){
    go.Add (other.transform.position.y);
    }
    if(other.transform.position.y == old){
    go.Remove(other.transform.position.y);
    }
    old = other.transform.position.y;
    }
    i need to add the positions of all objects is on triggers to a list but the problem that is adding the all position the ,old position and the new position of the objects is ontrigger, so what i need to do is when any objects is ontrigger and if he change his position mean move so, save the position of this object and delete his old position i need to do this for all objects is ontrigger

    thanks .
     
  2. Iblotn

    Iblotn

    Joined:
    Mar 13, 2015
    Posts:
    4
    some helps and thanks