I am trying to destroy a object by pressing space but not sure what i am doing wrong.
I am complete newbie at this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class attack : MonoBehaviour
{
public GameObject NPC;
private void OnTriggerEnter(Collider other)
{
if (Input.GetKey(KeyCode.Space))
{
Destroy(NPC);
}
}
}