I looked at the raycast documentation script on the unity website to try and understand raycasts. I was using the script and was wondering how i can change it to make the raycast know if it hit a certain collider then increase an int by 1 if it hit the correct collider.
(the code sample button isnt working properly so i have to insert the code here)
//
//
using UnityEngine;
using System.Collections;
public class Raycast : MonoBehaviour {
public float RayDistance = 5;
void Update() {
if (Input.GetButtonDown ("Fire1"))
{
Vector3 fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd, RayDistance))
print ("There is something in front of the object!");
}
}
}