Godot Version
4.2.2
Question
So I’m new to Godot, and have been trucking at a project for about a week now. It’s all been going fine and dandy but I loaded my project up today and there was this error: anything with pressing the ‘e’ key didn’t work as intended.
The thing is, every other keypress works fine, like WASD movement controls for the player, space to open inventory, but if I want to do the simple act of hiding a sprite when I press ‘e’, it doesn’t even register the keypress (I tested it using print statements). What am I supposed to do now?
For more reference, here’s the pickable-object code that uses an ‘e’ keypress (called “select” here) to make a sprite not visible.
extends Node2D
var state = “exists” #there are two states, picked and exists:
#picked is for when we have the plant, exists is for when we don’t
var ripe = false #ripe, like ripe-for-the-picking, which is what this plant is
@export var item: InvItem #this makes it so that the inventory version and the original version are attachable
var player = null #declare the presence of the player
func _process(_delta):
if state == “picked”:
$Sprite2D.visible = false
if state == “exists”:
$Sprite2D.visible = true
if ripe:
if Input.is_action_just_pressed(“select”):
state = “picked”
player.collect(item)
print(“got it”) #test
func _on_pick_area_body_entered(body):
if body.has_method(“player”):
ripe = true
player = body
func _on_pick_area_body_exited(body):
if body.has_method(“player”):
ripe = false
Also, there are no errors in the Output or Debugger windows. From the outside, nothing appears wrong with the program when I try to run it. It’s only just the keypress.