I’m building a 2d platformer and have just added a projectile attack to my player character. The only problem is the projectile spawns immediately when prompted, but id like it to spawn about 0.25 seconds after the keypress so to align with the throw projectile animation. It appears to me waitforseconds would be the most compact solution, but I cant seem to achieve the desired result.
if (Input.GetKeyDown(KeyCode.Tab) && Time.time - throwTime > 0.40) {
myAnimator.SetBool(“throw”, true);
throwTime = Time.time;
CastProjectile(0); //id like to delay CastProjectile
}
as shown I’ve got a time condition limiting when a keypress can be accepted to at least 0.40 seconds after the last keypress so a delay won’t conflict with the next delay