title: Unity Sword Collision Attack
body: <p>Hey guys I want to make a sword attack. But I get the error of:</p>
  
  <blockquote>
    <p>NullReferenceException: Object reference not set to an instance of an
    object</p>
  </blockquote>
  
  <p><strong>These are my codes:
  My weaponattack script:</strong></p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Weaponattack : MonoBehaviour
  {
      Enemy Enemy;
      public float power;
      // Use this for initialization
      void Start () {
  
      }
      // Update is called once per frame
      void Update () {
  
      }
      public void OnTriggerEnter(Collider col)
      {
         if(col.tag == "Enemy")
          {
              var kılıc = GetComponent&lt;Enemy&gt;();
              Enemy.currentHealt -= 10;
              Enemy.TakeDamage();
              Debug.Log("Düşman Vuruldu");
          }
      }
  }
  </code></pre>
  
  <p><strong>This is my Enemy Health scrpt:</strong></p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Enemy : MonoBehaviour {
      public float currentHealt;
      public float maxHealth;
      // Use this for initialization
      void Start () {
          currentHealt = maxHealth;
      }
  
      // Update is called once per frame
      void Update () {
  
      }
      public void TakeDamage()
      {
          currentHealt -= 10;
          if(currentHealt &lt; 0)
          {
              die();
          }
      }
      void die()
      {
          Destroy(gameObject);
      }
  }
  </code></pre>
  
  <p>Can you helo em I couldnt understan why these codes are not working why am I getting that error.</p>