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 & OnCollisionEnter dont run

Discussion in 'Scripting' started by Fjur, Nov 7, 2015.

  1. Fjur

    Fjur

    Joined:
    Oct 12, 2015
    Posts:
    13
    I have two cubes set up to test these functions, both have layers that can collide, both have box colliders and both have rigid bodies.

    Box A's collider is set as a trigger.

    Box B is a normal collider.

    Both are next to each other but Box B has a constant force that pushes it into box A.

    Box A has a script that runs the code for TriggerEnter & CollisionEnter

    When they hit nothing is triggered? Am I missing something?

    Code (csharp):
    1.  
    2.   void onCollisionEnter(Collider other)
    3.   {
    4.   print("Collided");
    5.   }
    6.  
    7.   void onTriggerEnter (Collider other)
    8.   {
    9.   print("Trigger");
    10.   }
     
  2. Fjur

    Fjur

    Joined:
    Oct 12, 2015
    Posts:
    13
    Well figured it out, first of all in OnCollisionEnter the parameter should be "Collision", the IDE didn't warn me about this because of the second problem which was onCollisionEnter should be OnCollisionEnter with the o capitalized, wasted a solid hour of my time haha