- Home /
Invoke.Repeating doesn't really "care" about repeat time?
My invoke.repeating doesn't seem to "care" about the repeat time at all? it just repeats incredibly quickly regardless of the time? Thanks
var Player : GameObject;
var Arms : GameObject;
var Ak74uShot : GameObject;
var AcrwShot : GameObject;
var KnifeShot : GameObject;
var Ak74uRange : int = 125;
var AcrwRange : int = 100;
var KnifeRange : float = 0.75;
var WeaponInt;
private var Ak74uFire : boolean = false;
private var AcrwFire : boolean = false;
function Start ()
{
}
function Update ()
{
var Ak74uRay : RaycastHit;
var AcrwRay : RaycastHit;
var KnifeRay : RaycastHit;
var WeaponInt = Player.GetComponent("Weapon Switch").GunEquipped;
if (WeaponInt == 1)
{
if (Input.GetMouseButton(0))
{
Physics.Raycast(Ak74uShot.transform.position, Ak74uShot.transform.forward, Ak74uRay, Ak74uRange);
Ak74uFire = true;
InvokeRepeating("Ak74uDamage", 0, 200000000000);
}
}
if (WeaponInt == 2)
{
if (Input.GetMouseButton(0))
{
Physics.Raycast(AcrwShot.transform.position, AcrwShot.transform.forward, AcrwRay, AcrwRange);
AcrwFire = true;
InvokeRepeating("AcrwDamage", 0, 200000000000);
}
}
if (WeaponInt == 3)
{
if (Input.GetMouseButtonDown(0))
{
Physics.Raycast(KnifeShot.transform.position, KnifeShot.transform.forward, KnifeRay, KnifeRange);
Debug.Log ("Melee");
}
}
Ak74uFire = false;
AcrwFire = false;
}
function Ak74uDamage()
{
Arms.animation.CrossFade("Rifle Recoil");
Debug.Log ("AK74U Fire");
}
function AcrwDamage()
{
Arms.animation.CrossFade("Rifle Recoil");
Debug.Log ("ACR-W Fire");
}
Comment
Best Answer
Answer by Fattie · May 29, 2013 at 07:50 AM
There is a famous bug in InvokeRepeating.
The first argument cannot be 0.0
Make the first argument say 0.0001
It's really amazing the guys at unity have not had a chance to fix this!
It's possible you have some other problem but this is the likely problem. Cheers
Thanks. $$anonymous$$y invokeRepeating does not change the speed in which it repeats. It's a little silly Unity hasnt been able to fix this
Your answer
![](https://koobas.hobune.stream/wayback/20220613103127im_/https://answers.unity.com/themes/thub/images/avi.jpg)