Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to detect enemy in effective way?

$
0
0
Hello, developers. Now, I have trouble with detecting enemy. Most of coders use Raycast when they need something to detect specific thing. But raycasting is not quite good, I think. For example, void ExampleCode() { ... RaycastHit hit; if(Physics.Raycast(player.position, player.forward, out hit, 15)) if(hit.transform.tag == "Enemy") Debug.Log("It's Enemy!"); ... } ![alt text][1] In this case, it is perfect what I wanted. But, what if in this case? ![alt text][2] Then we should plus the code like `player.back` But what if enemy is coming from 7'o clock? So, ultimately, I want to make player detect enemy in specific area like this. ![alt text][3] Is it possible with Raycast? or other ways? Thanks for reading. [1]: /storage/temp/21889-1.png [2]: /storage/temp/21890-2.png [3]: http://i.imgur.com/wnGMkPY.png

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>