melee attacks

how can i make melee attacks, just like your only weapon is a knife

Have a collider in front of your character. Keep track of what goes inside and out. Then when your melee attack key is pressed, hit the closest enemy (or all enemies) inside the collider. You can also use raycasts, and they have less errors in general, but they are a bit less realistic. Just cast one in the direction of your crosshairs (I’m assuming this is a fps or a 3rd ps) In general, I would use raycasts. They have less bugs.

There are plenty of questions like this one out there. Just search something like: melee, fps, combat etc.

Btw, your question is very… general. There’s no real specific answer to it, which is why it’s not the best question. To get better answers, perhaps you should revise your question. The FAQ is a great place to learn how to ask questions.