Search Unity

Question Button not working when displayed from marker

Discussion in 'AR' started by LMaschen, Apr 1, 2023.

  1. LMaschen

    LMaschen

    Joined:
    Feb 25, 2023
    Posts:
    1
    Hi,

    I'm currently making a simple AR app using AR foundation and ARCore in which the user can scan a marker and a 3D model will be displayed along with a button next to it that the user can tap to find information about the model.

    If I put the model and button directly in the world space without use of the marker, the button can be clicked and the information is displayed. However, when the prefab containing the model and button is displayed from the marker using an AR tracked image manager, the button can not be pressed.

    Anyone know why this might not be working?
    I'm thinking the marker might be displaying an image of the button rather than the actual button. Is there any way around this?
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Are you using Physics.Raycast? You can check out sample code to see how we handle raycasting onto GameObjects: https://github.com/Unity-Technologi...in/Assets/Scripts/Runtime/PlaceOnPlane.cs#L51

    The only other thing I can think is that something is blocking your raycast in the prefab version (ie the Collider is on a different GameObject or something). There is nothing unique about whether or not it's a prefab