Thursday, April 27, 2017

Day 40: Audio-only Game: Day 15

So, I finally figured out how to add the WaitForSeconds delay into the script. I first made a new void function:

I then added "StartCoroutine", and gave the coroutine a name: "Wait".


Finally, I added an IEnumerator with the "Wait" coroutine name. Inside that, I added "yield return WaitForSeconds(3);", and then a line afterwards that changes the CanAttack boolean to true.

I then simply added a line that calls the WaitToAttack function whenever the "1" or "2" key is pressed, effectively adding a delay that simulates drawing a sword, orpulling out a bow.















No comments:

Post a Comment