Hey all,
I’m trying to figure out raycasting by following a tutorial and nothing is working. I’ve attached the script to my camera and the click runs just fine but the ray isn’t created. Also the game is in 2d if that matters at all.
Here is my code:
using UnityEngine;
using System.Collections;
public class click : MonoBehaviour {
//public Camera camera;
void Update(){
if (Input.GetMouseButtonDown (0)) {
RaycastHit hitInfo;
Ray rayOrigin = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (rayOrigin, out hitInfo, 25f)) {
Debug.Log ("yo");
}
}
}
}