Hey people,
I am trying to get the parent of a gameobject i hit by raycast. Here is the script :
if(Input.GetButton("Mouse0")) {
var fwd2 = shootingPoint.transform.TransformDirection (Vector3.forward) ;
var hit2 : RaycastHit;
if (Physics.Raycast (shootingPoint.transform.position, fwd2, hit2, 50, cubeLayer)){
block2 = hit2.collider.transform;
block2parent = block2.transform.parent;
if (block2parent.tag==("BlockFree")){
blah blah blah
}
}
}
Unity gives me back the following error : " Cannot convert Unityengine.Transform to UnityEngine.GameObject.
I have tried many different syntax but could i could not get it right.
Any idea of the proper syntax ?
Thanks.