Instantiate bullet once when virtual joytick input is over 0.5?

Hi,
when my input is between 0f and 0.49f I can rotate the player with my joystick without shooting the bullets. BUT my Problem is that the amount of bullets are way to much when the input of my joystick is >= 0.5f || <= -0.5f, I just want 1 bullet to spawn than wait a little time until the bullet can be spawn again. How would you go about this? by the way the timeStamp-part doesnt really work

this is in my update()

float shootHorizontal = CrossPlatformInputManager.GetAxis ("shootHorizontal");
        float shootVertical = CrossPlatformInputManager.GetAxis ("shootVertical");
        shootInput = new Vector3 (shootHorizontal, 0f, shootVertical);
        //change 1f to smooth rotation
        transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (shootInput), 1f);
        if (shootHorizontal >= 0.5f || shootHorizontal <= -0.5f && Time.time >= timeStamp ) {
            //spawn bullets
            ShootBullets();
            timeStamp = Time.time + timeBetweenShots;
        }
        if (shootVertical >= 0.5f || shootVertical <= -0.5f && Time.time >= timeStamp ) {
            ShootBullets ();
            timeStamp = Time.time + timeBetweenShots;
        }
void ShootBullets(){
        var bullet = (GameObject)Instantiate (bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);

        bullet.GetComponent<Rigidbody> ().velocity = bullet.transform.forward * 6;
    }

I think you want extra parenthesis in there like:

if ((shootHorizontal >= 0.5f || shootHorizontal <= -0.5f )&& Time.time >= timeStamp )

I could be wrong, but other than that, it looks like it would work to me.

@fire7side thanks for your help, you were right :smile:

i changed the script a little bit for my needs but the concept is still the same
Here is the final method, if someone wants to use it.
put this in the update method and change the fireRate to your needs

waitTilNextFire -= Time.deltaTime * fireRate;
void ShootBullets(){
        float shootHorizontal = CrossPlatformInputManager.GetAxis ("shootHorizontal");
        float shootVertical = CrossPlatformInputManager.GetAxis ("shootVertical");
        shootInput = new Vector3 (shootHorizontal, 0f, shootVertical);
        //change 1f to smooth rotation
        transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (shootInput), 1f);


        if((shootHorizontal >= 1f ||  shootVertical >= 1f)  && waitTilNextFire <= 0f){

            //var bullet = (GameObject)Instantiate (bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
            var bullet = (GameObject)Instantiate (bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
            bullet.GetComponent<Rigidbody> ().velocity = bullet.transform.forward * 6;

            waitTilNextFire = 1f;

        }
        if ((shootHorizontal <= -1f || shootVertical <= -1f) && waitTilNextFire <= 0f) {
            var bullet = (GameObject)Instantiate (bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
            bullet.GetComponent<Rigidbody> ().velocity = bullet.transform.forward * 6;

            waitTilNextFire = 1f;
        }