I'm an absolute beginner with Unity and Vuforia. For my Bachelor thesis, I'm working on an AR Application augmenting a physical 2D Map. For filtering the content I tried to use some 3D buttons on the side which execute different filter options.
On youtube, I found several videos to setup raycast to track model hits through touch interaction. For testing, i copied the code from the video.
I attached the script as he does in his video (https://www.youtube.com/watch?v=hi_KDpC1nzk) to my image target.
My 3D Button (Cube) is a child of it with a mesh collider on it.
Whatever I do my camera / android device does not detect any hits at all. For reasons I never get into the needed part of the function cause (Physics.Raycast(ray, out hit) never returns true...
I am absolutely clueless to what else I could do to make this work. I`ve already tried each advice I found on several forums and or videos.
This is the code I use:
public class buttonController : MonoBehaviour
public AudioClip audioClips;
public AudioSource myAudioSource;
private void Start()
myAudioSource = GetComponent<AudioSource>();
private void Update()
if (Input.touchCount > 0 && Input.touches .phase == TouchPhase.Began)
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
btnName = hit.transform.name;
myAudioSource.clip = audioClips;
I would appreciate it so much if anyone has a clue or hint.