2D Top Down Combat: How to only damage enemy that the player is facing? Up,down,left,right
Title pretty much says it all. I can't find a solid way that works. I just need to detect if the player is directly facing an enemy and then I can call my damage function. I just don't know how to find if the player is facing the enemy. So far all I can get is killing enemies all around the player instead of directly in front of him.
Any help is much appreciated!!!
How are you detecting collisions? You could place collider in front of the player by parenting it. There's also transform.forward that might be useful if detection is done only in code.
Answer by Bluestone19 · Jun 22, 2016 at 01:25 AM
Raycasts are a possible solution. You can find tutorials all about Raycasts (you might want to look for Raycast2D tutorials specifically) on youtube, and there's also the unity help site.
Your answer
![](https://koobas.hobune.stream/wayback/20220612083305im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D TopDown Combat. How to damage enemy that player is facing? 0 Answers
Making a 2D Point and Click Movement System 0 Answers
Topdown 2D Colliders Not Working, help! 0 Answers
Adding small acceleration to 2d top down movement game? 0 Answers
What is the best solution for infinite tile generation in a 2d top down game? 0 Answers