I was wondering if you guys could tell me whats wrong with my C# script.
using UnityEngine;
using System.Collections;
public class HealthScript : MonoBehaviour {
/// <summary>
/// health
/// </summary>
///
public int hp = 1;
/// <summary>
/// The is player.
/// </summary>
public bool isPlayer = true;
/// <summary>
/// inflicts damage and ends the game.
/// </summary>
/// <param name="DamageCount"></para>
public void Damage(int damageCount){
hp -= damageCount;
if (hp <= 0)
{
Destroy (gameObject);
}
}
void OnTriggerEnter2D(Collider2D otherCollider)
{
// have you been eaten?
EatenScript eaten = otherCollider.gameObject.GetComponent<EatenScript>();
if ( eaten != null)
{
if(eaten.isPlayerEaten != isPlayer)
{
Damage(eaten.damage);
Destroy(player.gameObject);
}
}
}