I have a game board with different tiles and other elements on them. There’s a huge plane underneath it, acting as a floor. I wrote a simple script (and attached to main camera) to hit a ray on the game object and return the object’s name.
function Update () {
var fwd = transform.TransformDirection (Vector3.forward);
var Hit : RaycastHit;
if (Physics.Raycast (transform.position, fwd, Hit, 1000))
Debug.Log(Hit.collider.name);
}
I set the plane (floor) to Ignore Raycast and also set all such objects which I don’t care about, to this layer. Yet, the script doesn’t print the tile names! i.e There’s no output seen in the log. I don’t know what’s going on here.
Please help!