Godot Version
4.3
Question
How to make it so that when a body enters an Area2D node and a button is pressed (for example, Enter), a function is performed.
extends Area2D
@onready var arrow = load("res://Scenes/arrow.tscn")
func _on_body_entered(body: Node2D) -> void:
if body.name == "Player":
if Input.is_action_just_pressed("enter"):
shoot()
func shoot():
var instance_arrow = arrow.instantiate()
add_child(instance_arrow)
Please help!