I have a raycast set up, but I need to detect if the raycast is touching an object (var enemy : Transform to be exact).
I am not sure if this answers your question. I would assume that you can use the tag of the gameObject to get details.
e.g.
var hit : RaycastHit;
if (Physics.Linecast (transform.position, target.position, hit))
{
if (hit.collider.gameObject.tag == "Enemy")
{
Debug.DrawLine (transform.position, hit.point, Color.yellow);
enemyDetected = true;
}
}
I think you maybe asking if you can compare whether the hit.collider.transform is the same as your predefined enemy.transform. I am not sure if you can do this, I guess I would try if (hit.collider.transform == enemy.transform) As the transform is an array I have no idea if that would work. I am still relatively new to unity.
Hope that helps.
Ergs