Quantcast
Channel: Questions in topic: "invokerepeating"
Viewing all articles
Browse latest Browse all 220

InvokeRepeating() not working.

$
0
0
I am trying to fire bullets at a rate determined by the weaponFireRate variable, but no matter what I do it will always fire one bullet per seconds. Here is the code: public int health; public int playerSize; public int weaponDamage; public float weaponFireRate = 10.0f; public int bulletSpeed = 10; public int bulletSize; public GameObject bullet; private bool shooting = false; // Use this for initialization void Start () { InvokeRepeating("Shoot", 0.0f, (1.0f / weaponFireRate)); } // Update is called once per frame void Update () { shooting = false; if (Input.GetButton("Fire1")) { Shoot(); shooting = true; } } void Shoot() { if (!shooting) return; GameObject bulletClone; bulletClone = Instantiate(bullet, transform.position, transform.rotation); bulletClone.GetComponent().AddForce(bulletClone.transform.up * bulletSpeed); } Any help would be greatly appreciated!

Viewing all articles
Browse latest Browse all 220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>