Here is the code. When I press a key, the cube should appear, and when I let go, it disappears, but nothing comes out.
I checked using debug.log and the part where the left or right mouse button is pressed and the action is performed - DOES NOT WORK. Why? Explain, please.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class KillHit : MonoBehaviour { public GameObject hitb; // Use this for initialization void Start () { hitb = GameObject.Find("killcube"); } // Update is called once per frame void Update () { if(Input.GetMouseButton(0) || Input.GetMouseButton(1)){ hitb.gameObject.SetActive(true); }else{ hitb.gameObject.SetActive(false); Debug.Log("Works1"); } } void OnTriggerEnter2D(Collider2D other) { if(other.gameObject.tag == "enemy01") { Destroy(other.gameObject); } } }