Quantcast
Channel: Answers by "Kleptomaniac"
Viewing all articles
Browse latest Browse all 90

Answer by Kleptomaniac

$
0
0
Just use a raycast from your cursor coordinates. Like so: void Update () { if(Input.GetButtonDown("Fire1")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if(Physics.Raycast(ray, hit, 100)) { if (hit.collider.gameObject.tag == "enemy") { selectedTarget = hit.collider.gameObject; } } } } You may need to fit it into your code a bit better as you see fit. Hope that helps, Klep

Viewing all articles
Browse latest Browse all 90

Trending Articles



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