I’m making a side-scrolling shoot em’up game in Unity. I put the following code on an enemy character to put a special move gauge in the game, but it turns out to be null and doesn’t respond at all. Please tell me what to do.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyCore : MonoBehaviour {
public float HP = 1;
public int GetScore = 400;
public float GetPower = 10;
public GameObject Explotion;
void Awake(){
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(HP <= 0){
Destroy(gameObject);
Instantiate(Explotion,transform.position,transform.rotation);
ScoreScript.ScoreValue += GetScore;
Ship Ship = GetComponent<Ship>();
Ship.Hyper.CurrentVal += 10;
}
}
void OnTriggerEnter2D(Collider2D other){
if(other.gameObject.tag == "Player Bullet"){
HP -= 1;
}
if(other.gameObject.tag == "Player Mega Bullet"){
HP -= 3;
}
if(other.gameObject.tag == "Player Giga Bullet"){
HP -= 5;
}
}
}