Raycast with Cardboard

Helloooo

I am using the Cardboard clicker to move the Camera, Done √

But want to use the Raycast hit from the Camera to trigger smaller events.

What’s wrong with the following code:

	private Camera cam;
	public GameObject trigger;
	public bool myTrigger = false;
	public GameObject myShow;
	// public GameObject myHide;



	// Update is called once per frame
	void Update () {

		if(Physics.Raycast(cam.transform.position, trigger.transform.position, Mathf.Infinity))			{

			if (myTrigger == false) {
				myShow.SetActive (true);
				//myHide.SetActive (false);
			} else {
				myShow.SetActive(true);
				//myHide.SetActive(true);
			}
				
			}
	
	}

Thanks!

~be

well first of all raycast is not stated in two positions. its stated as (startpoint, direction, distance).

the direction part is stated as a vector 3 direction variable
you can get vector 3 direction by subtracting 2 points.

so your raycast should be stated like this:

 if(Physics.Raycast(cam.transform.position,cam.transform.position-trigger.transform.position, Mathf.Infinity))