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. Dismiss Notice

I tried but OnCollisionEnter isnt work?

Discussion in 'Scripting' started by Ericmatheus, Sep 23, 2014.

  1. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    I reaaly dont know why

    I tried with collision,object.tag and object.name but it doesnt work
     
  2. Rutenis

    Rutenis

    Joined:
    Aug 7, 2013
    Posts:
    297
    Note that collision events are only sent if one of the colliders also has a non-kinematic rigid body attached. Or basically, you need one of your GameObjects that youre colliding with, to have a rigidbody component attached to it.
     
  3. SkillBased

    SkillBased

    Joined:
    Aug 11, 2014
    Posts:
    141
    You also need to use the right Collider type as an parameter to your OnCollisionEnter()

    If you have a 2D Collider you use: OnCollisionEnter(Collider2D other)

    If not, try all the other permutations of Collider types until the event is triggered.