infinite_ammo

Farter.cs

Feb 17th, 2015
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Farter : StateMonoBehaviour
  5. {
  6.     void Start()
  7.     {
  8.         SetState(Normal);
  9.     }
  10.  
  11.     IEnumerator Normal()
  12.     {
  13.         while (true)
  14.         {
  15.             if (Input.GetKeyDown(KeyCode.F))
  16.                 SetState(Fart);
  17.             yield return null;
  18.         }
  19.     }
  20.  
  21.     IEnumerator Fart()
  22.     {
  23.         Debug.Log("now farting!");
  24.         // play some animation or something
  25.         // wait a second
  26.         yield return new WaitForSeconds(1f);
  27.         // go back to normal state
  28.         SetState(Normal);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment