I am trying to use a grenade in my game to inflict damage on any and all enemies within a certain range using RayCast and SphereCastAll, but when I try to tell the script to send a damage message to objects that are hit, I get the error: ‘SendMessage’ is not a member of ‘UnityEngine.RaycastHit’. This is the code:
var hit: RaycastHit[] = Physics.SphereCastAll(transform.position, explosionRadius, transform.up, explosionDistance);
//apply damage to all surrounding objects
for( var hitObject in hit)
{
hitObject.SendMessage("SevereDamage", SendMessageOptions.DontRequireReceiver);
}
If I remove the hitObject before the SendMessage, the error goes away, but of course I cannot do that. Does anyone know what to do? (Note: I am not familiar with JavaScript, most of this was taken from another source. I do realize that it could just be a JavaScript thing, but I really don’t know).