Hi all, I have a simple script to select a gameobject to be the selected unit.
However, after 10 seconds or so - Input.GetMosueButtonDown doesnt work anymore.
I have put this method in Update(). Does anyknow what the problem can be? It works for 10 seconds and then it stops working.
public void RangedAttack()
{
if(Input.GetMouseButtonDown(1))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit))
{
if(hit.transform.tag == "Enemy")
{
selectedUnit = hit.transform.gameObject;
Debug.Log(hit);
}
}
}
}