Advertisement
Guest User

Untitled

a guest
May 28th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. //This is inside update
  2. if (Input.GetKey(KeyCode.Z)) {
  3.     canReinforcements = true;
  4. }
  5.  
  6. if (canReinforcements)
  7.     StartCoroutine (callReinforcements ());
  8.  
  9.  
  10. //Then coroutine
  11.  
  12. public IEnumerator callReinforcements() {
  13. if (reinforcements.transform.position.z < -3.74 && canReinforcements) { //if below screen
  14.     reinforcementsBoxCollider.enabled = true; //enabled box collider since it's resting position is on lower boundary
  15.     reinforcements.transform.Translate (0, 0, -2.5f * Time.deltaTime); //move up from below screen
  16. }
  17. yield return new WaitForSeconds (10f);
  18. canReinforcements = false;
  19. if (reinforcements.transform.position.z > -10) //if above screen
  20.     reinforcements.transform.Translate (0, 0, 2.5f * Time.deltaTime); //move below screen
  21.    
  22. reinforcementsBoxCollider.enabled = false;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement