Hello, i am working working on a shooter and I need the game to wait for a few seconds, say 5, when the reload command is pressed to give time for my reload animation to play. I am trying to use the code below, which i constructed after consulting the scripting reference and a few other posts in the forums, but it does not work, I don’t get any error messages but the game just reloads instantly without raking notice of the delay. Any help on this would be greatly appreciated, Thanks you.
Jack
Here is my code.
void Reload()
{
reloadtimer(5.0f);
Player.GetComponentInChildren<PlayerAmmo>().clipsize = Player.GetComponentInChildren<PlayerAmmo>().clipmax;
Player.GetComponentInChildren<PlayerAmmo>().AmmoCount -= Player.GetComponentInChildren<PlayerAmmo>().clipsize;
}
IEnumerator reloadtimer(float delay)
{
yield return new WaitForSeconds(delay);
}