Hello All… I’m messing around with a Third person Shooter, Atm the character reloads Instantly so its very unrealistic so i created a float
public float reloadTime;
then inside my reload function i added
yield return new WaitForSeconds(reloadTime);
But this causes issues so i changed Void Reload() to IEnumerator Reload() The Error goes away but now the reload function isn’t being called.
This is the reload Function “NON edited”
public void Reload() {
Debug.Log("Reload [" + weaponsSet[weaponIndex].weaponName+"]");
int needBullets = (weaponsSet[weaponIndex].clipSize - weaponsSet[weaponIndex].currentBulletsCount);
if (weaponsSet[weaponIndex].haveBullets >= needBullets){
weaponsSet[weaponIndex].haveBullets -= needBullets;
weaponsSet[weaponIndex].currentBulletsCount = weaponsSet[weaponIndex].clipSize;
}
else{
weaponsSet[weaponIndex].currentBulletsCount = weaponsSet[weaponIndex].haveBullets;
weaponsSet[weaponIndex].haveBullets = 0;
}
}
I really only the basics of Javascript so C# is really confusing me and i don’t understand what im doing wrong.
Cheers! This works.
– AusAndrew19Dang got to it before me lol, good answer +1 :)
– clunk47Unity Gems has a much better [article on coroutines][1], for C# (and not only) "confused noobs" :) [1]: http://unitygems.com/coroutines/
– ArkaneX@ArkaneX good ref, +1
– clunk47@ArkaneX Thanks for the link to Unity Gems, I have quite enjoyed the past 2 hours reading and watching videos there :)
– numberkruncher