The post looks good to me except title.
In general title should be about what you are trying to achieve and not what you think solution is - check What is the XY problem? for reasons. I'd go for something along the lines of:
How to detect collision with sword and enemy (narrow sector unlike fireball)
Body should include
- clear description what you want to achieve (check, also adding something like "causing damage to enemy in front of player" to first sentence may help)
- what you've tried (check - code for distance check, attempt at raytracing)
- why what you found did not work (sort of check - good explanation for distance one, very strange statement that raytracing does only work in 3d and no mentioning that you need to cast multiple rays for sector detection)
- reiterate what you are looking for (check - asking about actual problem, not "how to use raytracing").