Search Unity

Resolved OnCollisionEnter not working

Discussion in 'Physics' started by caden3ds, Feb 15, 2024.

  1. caden3ds

    caden3ds

    Joined:
    May 17, 2017
    Posts:
    33
    I have 2 spheres with sphere colliders (istrigger is off) controlled by VR controllers, with the root gameobject having a rigidbody on continuous dynamic and isKinematic off, and a cube collider which I'm trying to collide with. The sphere and the cube collide like normal but OnCollisionEnter isn't called.
    This is the script: (which is on the gameobject with the collider and I also tried putting it on the root gameobject with the rigidbody)
    private void OnCollisionEnter(Collision hit)
    {
    Debug.Log("collision detected");
    }
    Contact pairs mode is on all, layers included is on everything, layers are set to default.
     
  2. caden3ds

    caden3ds

    Joined:
    May 17, 2017
    Posts:
    33
    Also tried dropping a sphere with a rigidbody onto the cube and it still didn't call
     
  3. caden3ds

    caden3ds

    Joined:
    May 17, 2017
    Posts:
    33
    Fixed itself
     
  4. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    49
    I also encountered this problem. Although everything worked fine in my game before. Collisions work, but the OnCollisionEnter method is not called. How did you fix this problem?
     
  5. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635