How can i add melee atacks in a fist person 3d game

Godot Version



i want to do melee combat on godot 4 3d for a first person game how can i do it?

You want to detect other objects so adding an Area3D for the detection is a good first step.
Then you want to find the bodies in the area. You can achieve this with the get_overlapping_bodies method on the Area3D class.
The bodies you want to detect should have some kind of health script attached. Your system could look like this:

func on_input():
    for body in _area.get_overlapping_bodies():
        if body.has_method("damage"):