Advertisement
kasru

Enemy Selection System

Jul 13th, 2015
1,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. //****** Donations are greatly appreciated.  ******
  2. //****** You can donate directly to Jesse through paypal at  https://www.paypal.me/JEtzler   ******
  3.  
  4. void Update () {
  5.  
  6.     if(Input.GetMouseButtonDown(0)) {
  7.  
  8.         SelectTarget();
  9.     }
  10. }
  11.  
  12. void SelectTarget () {
  13.  
  14.     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  15.     RaycastHit hit;
  16.  
  17.     if(Physics.Raycast(ray, out hit, 10000)) {
  18.  
  19.         if(hit.transform.tag == "enemy") {
  20.  
  21.             selectedUnit = hit.transform.gameObject;
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement