Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnCollisionEnter can't work (Objects repelling themselves)

Discussion in 'Physics' started by Zappppp, Feb 10, 2019.

  1. Zappppp

    Zappppp

    Joined:
    Dec 5, 2018
    Posts:
    9
    Hi! I'm trying to make a glass break when the player touches it with the OnCollisionEnter void, but it can't work because they are repelling themselves...
    The glass has a RigidBody (No gravity) and a BoxCollider (Isn't trigger), and the player has RigidBidy (With gravity) and a CapsuleCollider (Is trigger), here's the code for the glass:
    Code (CSharp):
    1. void OnCollisionEnter(Collision collisioner)
    2.     {
    3.         Debug.Log("Worked"); //Doesn't work either, so it comes from the collision itselfs
    4.         if (collisioner.collider.tag == "Player")
    5.         {
    6.             Destroy(gameObject);
    7.         }
    Can someone help me please? ;-;