Swipe to kill enemy? 2D

I have enemies that are constantly approaching my player. I want to be able to swipe across them with a finger to, essentially, cut them in half. For now, as long as they disappear, that’s fine. I can figure out how to do death animations later.

So far, I have:

  function OnMouseUpAsButton () 

Which works great for tap killing. But I need swipe killing. Any advice? I’ve read a bit about raycasting but I’m not sure if that’s what I need. Any help is appreciated!

You should store the start position and start time of the touch. Then when the player stops touching the screen you know what line he has drawn on the screen and how long it took. If this line was drawn relatively fast then it’s a swipe, and if it goes through enemies then they should die.

Use Input.GetTouch(0) and use its phase to know if it just started or just ended.