Question by 
               heltonluizsb · Jan 31, 2020 at 10:08 PM · 
                script.touchraycasthitonmousedowntouches  
              
 
              How "select" the enemy even with joystick being used
Hi!
I created a script and put it On my enemy, where when player click on the enemy, the enemy is selected:
 public void OnMouseDown()
 {
     player.GetComponent<PlayerMovement>().target = this.gameObject;
     gameManagement.enemieWasClicked = true;
 }
But when I test in my Android phone, when I'm using the joystick button (A UI with a Joystick Script get at Assets Store), I can't select the enemy. After I tried a funciton created in GameManager Script and nothing happens... Need help, plz
 [SerializeField] private Vector3 touchPosition;
 [SerializeField] private RaycastHit hit;
 [SerializeField] private TextMeshProUGUI testtext;
 
 public bool enemieWasClicked;
 public PlayerMovement player;
 
     void GetTarget()
     {
         if (Input.touchCount > 0)
         {
             for (int i = 0; i < Input.touchCount; i++)
             {
                 touchPosition = Camera.main.ScreenToWorldPoint(Input.touches[i].position);
                 int pointsToInt = (int)points;
                 testtext.text = pointsToInt.ToString();
                 Debug.DrawLine(Vector3.zero, touchPosition, Color.red);
                 var ray = Camera.main.ScreenPointToRay(touchPosition);
                 if (Physics.Raycast(ray, out hit))
                 {
                     player.target = hit.collider.gameObject;
                     enemieWasClicked = true;
                 }        
             }        
         }
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                