Basically, I am trying to make certain objects tagged Barrels explode when hit with a ray cast. I am getting the compiling error of BCE0077: It is not possible to invoke an expression of type ‘String’.
Here is my script:
// Prints the name of the object camera is directly looking at
var explosion : Transform;
function Update () {
if (Input.GetButtonDown("Fire1"))
// Get the ray going through the center of the screen
var ray : Ray = camera.ViewportPointToRay (Vector3(0.5,0.5,0));
// Do a raycast
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
print ("I'm looking at " + hit.transform.name);
if (Physics.Raycast (ray, hit))
Debug.DrawLine (ray.origin, hit.point);
if (Physics.Raycast (ray, hit))
Destroy(hit.collider.gameObject);
if (hit.collider.gameObject.tag ("Barrels")){
Instantiate (explosion, transform.position, transform.rotation);
}
}