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

Question ARFoundation Collision between AR Camera and game objects

Discussion in 'AR' started by jg1209, Nov 27, 2020.

  1. jg1209

    jg1209

    Joined:
    Feb 11, 2020
    Posts:
    3
    Hi,

    Does anyone have any ideas on detecting a collision between an AR Camera/AR Session Origin and any objects that are in a game? This would be to add some sort of indicator to the app, for clarity for the users.

    All the standard ways I can think of - such as adding a character controller to the AR Camera and using collisions between than and any other 3D Game Object (with collider and rigidbody) doesn't seem to be working - unless I've missed something!

    Something like this.
     
  2. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Hi,

    I use a capsule collider on ARCamera component. And use colliders as trigger on the others objects to detect collision.

    I think it's not the best, but it's work.

    Best,
    Alexis
     
  3. jg1209

    jg1209

    Joined:
    Feb 11, 2020
    Posts:
    3
    That makes sense - the problem I now keep coming up against is that the collider on the ARCanmera component keeps detecting collisions with the ARPlane prefab - any workaround? As I want to have the trigger on the ARCamera so that it plays audio/does some visual stuff every time you collide with anything (except the Plane!)
     
  4. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    You can used different Layer on Plane and ARCamera.

    And disable physics between them in Project Settings -> Physics
     
  5. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    306
  6. charuvdhn02

    charuvdhn02

    Joined:
    Oct 2, 2020
    Posts:
    3
    Hey do you found some solution for this?
    I am facing the same issue .
    Please can you help
     
  7. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    To do that, you need to attach a Collider and a RigidBody on the ARCamera.

    If you have a problem with the ARCamera rotation. Create an empty GameObject, attach the Collider and the RigidBody and update the position base on the ARCamera position.

    Best,
    Alexis