Hello, so I was recently testing the editor to see if there was a bug regarding automatic key press. I simply added a plane, cube, and a script attached to the cube here:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class keyPressBug : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.S));
{
Destroy(gameObject);
print("s pressed");
}
}
}
As shown, I want the cube to disappear only when I press the key. However, the cube disappears right after I hit the play button and it prints to let me know that the key was already pressed! How can I resolve this issue?