Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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.