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

OnTriggerEnter is only called once with multiple triggers.

Discussion in 'Scripting' started by GreenBoxInteractive, Jun 23, 2015.

  1. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    I have this code.

    Code (CSharp):
    1.     void OnTriggerEnter(Collider col){
    2.         Instantiate (pref, new Vector3(0, col.transform.position.y + yOffset, -10), Quaternion.identity);
    3.         Debug.Log("hitTrig");
    4.     }
    It is attached to a player that is moving upwards towards the triggers, the "pref" object has a trigger in it, and when the player passes through it, it spawns another one of itself, but it only works for the first trigger, then when it reaches the second one and passes through it, the code is not called.

    My player is using FixedUpdate to move (I think it is relevant?)
     
  2. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    Misaligned triggers. Never work at 1:45 am.
     
    Komizart, LeftyRighty and BenZed like this.