Search Unity

Question AR Collision between two gameObejcts

Discussion in 'AR' started by kashishs, Oct 16, 2022.

  1. kashishs

    kashishs

    Joined:
    Apr 28, 2020
    Posts:
    5
    hello,
    I'm starting off with AR and wanted to know how can we detect collision between two Game Objects in AR. Thanks!
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
  3. kashishs

    kashishs

    Joined:
    Apr 28, 2020
    Posts:
    5
    Thanks for your reply. I was thinking the same. But for some reason my objects don't. The white cube is a spawned object whereas the red one is to be destroyed. I did some tests where after removing the spawn script, the red one does get destroyed on collision.
     

    Attached Files:

  4. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    If you are using AR Foundation 5.0, I recommend testing your scene using XR Simulation so you can more easily debug your scene in the Editor. A common cause for OnCollisonEnter not firing is that one of the objects is missing a Collider (both objects need a Collider) or one object doesn't have a RigidBody (at least one object needs a non-kinematic RigidBody)
     
  5. kashishs

    kashishs

    Joined:
    Apr 28, 2020
    Posts:
    5
    Thanks. I will check it out and update
     
  6. kashishs

    kashishs

    Joined:
    Apr 28, 2020
    Posts:
    5
    I redid the entire thing and the problem was resolved. Thanks!
     
    andyb-unity likes this.