How to Make My Character Can Attack Enemies ?

Hi, I’m creating a platformer game for Android. And I have a player and my player can do some attack(punch). What I want to do is whenever my Player press Attack Button, it play an Punch Attack Animation and do some damage to enemy that collide with my Player punch.

I’m sorry if I don’t explain it well :).

If it’s a sprite based game you could approach your problem with creating frames for your attack animation, arrange them, have some invisible collider which toggles on/off in the front of the player and when you want to attack, call it with;

if (Input.GetButton("Attack")
Animation.Play("YourAnimationName");

Of course you need to set up the “Attack” button in the Input manager…

As for damage on collision (set collider to trigger), use

Void OnTriggerEnter2D(Collider c){
//your stuff
}

Yeah finally. Thanks for your help!