I did the code for this lecture but the projectiles won’t hit.
Here’s the code for my EnemyBehavior:
using UnityEngine;
using System.Collections;
public class EnemyBehavior : MonoBehaviour {
public float health = 150;
void onTriggerEnter2D(Collider2D collider){
Projectile missile = collider.gameObject.GetComponent<Projectile>();
if (missile) {
health -= missile.GetDamage();
missile.Hit();
if (health <= 0) {
Destroy(gameObject);
}
}
}
}
And the code for my Projectile:
using UnityEngine;
using System.Collections;
public class Projectile : MonoBehaviour {
public float damage = 100f;
public void Hit(){
Destroy(gameObject);
}
public float GetDamage(){
return damage;
}
}
Pls help! Thanks!