I am trying to have a script check if a variable is not equal to 0 in another script. This the error I’m getting:
NullReferenceException: Object reference not set to an instance of an object
EnemyAI.Update () (at Assets/Scripts/EnemyAI.cs:20)
Code accessing other code:
void OnTriggerEnter2D(Collider2D col){
if (col.gameObject.tag == "Bullet") {
var move = gameObject.GetComponent<MoveTrail>();
if(move.moveSpeed != 0){
air = air - 10;
}
}
}
Script MoveTrail’s moveSpeed is an int.