- Home /
enemies Scoring points killed
Hello, how can I make a score for each killed enemy? I tried to follow this guide: https://unity3d.com/learn/tutorials/projects/survival-shooter-tutorial/scoring-points
But can not I :(
In my code I also use the spawning of the enemies and it is the following:
Enemy script manager
public class Zombie : MonoBehaviour {
protected float damage = 1.0f;
protected float health = 1.0f;
protected float velocityFactor = 1.0f;
protected NavMeshAgent agent;
protected ParticleSystem explosion;
void Update(){
agent.destination = GameManager.GetCharacter ().transform.position;
if(!explosion.IsAlive() && explosion.gameObject.activeSelf){
Death ();
}
}
public void SetVelocity(float value){
agent.speed = value;
}
public void SetDamage(float value){
damage = value;
}
public void SetHealth(float value){
health = value;
}
public float GetVelocity(){
return agent.speed;
}
public float GetHealth(){
return health;
}
public float GetDamage(){
return damage;
}
void ApplyDamage(float damage)
{
if (health <= 0.0f) {
StartExplosionParticle ();
}
health = health - 1;
}
void OnCollisionEnter (Collision coll)
{
if (coll.gameObject.tag == "Bullet")
{
ApplyDamage (1.0f);
}
if (coll.gameObject.tag == "Bullet")
{
ApplyDamage (1.0f);
}
if (coll.gameObject.tag == "Bullet")
{
ApplyDamage (1.0f);
}
}
private void Death(){
Destroy (gameObject);
GameManager.spooneEngine.GetCurrentWave ().Remove (gameObject);
}
private void StartExplosionParticle(){
gameObject.GetComponent<MeshRenderer> ().enabled = false;
gameObject.GetComponent<BoxCollider> ().enabled = false;
explosion.gameObject.SetActive (true);
explosion.Play ();
}
}
And in every enemy he has this script:
public class FatZombie : Zombie {
void Awake(){
explosion = transform.GetChild (0).GetComponent<ParticleSystem> ();
agent = GetComponent<NavMeshAgent> ();
health = 5.0f;
damage = 2.0f;
velocityFactor = 1.5f;
}
public float GetVelocityFactor(){
return velocityFactor;
}
}
how can I do?
Comment