so what I’m trying to do here is to active a shield every time the player touch the screen and after 10 sec player can set it active again,
my problem is that the update function only active it once and after 10 sec I keep clicking like +10 click then it active it again
here is the code
public GameObject shield;
bool canClink= true;
private float timetonextclick;
void Start () {
}
public void Update () {
if (Input.touchCount > 0) {
Touch touch = Input.GetTouch (0);
if (touch.type == TouchType.Direct) {
if ( canClink == true ) {
GameObject myShield = (GameObject)Instantiate (shield, transform.position, Quaternion.identity);
CreateShield shieldScript = myShield.GetComponent<CreateShield> ();
shieldScript.myOwner = this.gameObject;
canClink = false;
timetonextclick = 0.0f;
}
if (canClink == false) {
timetonextclick += Time.deltaTime;
}
if (timetonextclick >=10f) {
canClink = true;
}
}
}
}
}
is there something wrong in the code which make this weird behavior?