I need to be able to detect if an enemy is collided with the SphereCast and if so add that enemy to an an Array. My problem is that the counsel gives me an error saying "collided is not a memeber of unit RaycastHit.
var enemysInRange = new Array();
function Update () {
if(Physics.SphereCast(transform.position, 50, transform.forward, hits, 0.1)){
Debug.Log(hits.collider.tag);
}
}
function OnCollisionStay(collided : Collision){
if(hits.collided.tag == "Enemy"){
enemysInRange.Push(hits.gameObject);
Debug.Log("Unit Pushed");
}
}
↧