Help

Now it says Enemy.CanBeHarmed is not used what is going on here and how do I fix it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    [SerializeField] float EnemyHp = 100f;

    [SerializeField] bool CanEnemyBeHarmed;

    public void Harm(float HarmHp)
    {
        if(CanEnemyBeHarmed = true);
     {
        if(EnemyHp > 0)
        {
            EnemyHp = EnemyHp - HarmHp;
        }
      
     }
    }

    void Update()
    {
      if(0 >= EnemyHp);
      {
       GetComponent(MeshRenderer).enabled = false;
      }
    }
}


}

Do you have your console window open or a configured IDE? This code has lots of compile errors in it, you need to fix all of those before you can attach it to anything.

1 Like

This isn’t much different from your previous post here. Please edit your posts to use code-tags rather than using plain text.

I’ll also move this post to the Getting Started forum for you which is a much more appropriate forum! :slight_smile:

Thanks.

2 Likes

Please use a single thread for a problem. Closing this as you’ve now made a duplicate here .