Advertisement
Guest User

I realised....

a guest
Feb 5th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class characterSelection : MonoBehaviour {
  5.  
  6.     public bool firstIsEnabled = true;
  7.     public bool secondIsEnabled = false;
  8.     public bool thirdIsEnabled = false;
  9.     public Transform firstCharacter;
  10.     public Transform secondCharacter;
  11.     public Transform thirdCharacter;
  12.  
  13.     void Update () {
  14.         if (Input.GetKeyDown(KeyCode.F1) && firstIsEnabled == true) {
  15.             GetComponent<characterController>().enabled = false;
  16.             secondCharacter.GetComponent<characterController>().enabled = false;
  17.             thirdCharacter.GetComponent<characterController>().enabled = false;
  18.         }
  19.  
  20.         if (Input.GetKeyDown(KeyCode.F1) && firstIsEnabled == false) {
  21.             GetComponent<characterController>().enabled = true;
  22.             secondCharacter.GetComponent<characterController>().enabled = false;
  23.             thirdCharacter.GetComponent<characterController>().enabled = false;
  24.         }
  25.  
  26.         if (Input.GetKeyDown(KeyCode.F2) && secondIsEnabled == true) {
  27.             GetComponent<characterController>().enabled = false;
  28.             secondCharacter.GetComponent<characterController>().enabled = false;
  29.             thirdCharacter.GetComponent<characterController>().enabled = false;
  30.         }
  31.        
  32.         if (Input.GetKeyDown(KeyCode.F2) && secondIsEnabled == false) {
  33.             GetComponent<characterController>().enabled = false;
  34.             secondCharacter.GetComponent<characterController>().enabled = true;
  35.             thirdCharacter.GetComponent<characterController>().enabled = false;
  36.         }
  37.  
  38.         if (Input.GetKeyDown(KeyCode.F3) && thirdIsEnabled == true) {
  39.             GetComponent<characterController>().enabled = false;
  40.             secondCharacter.GetComponent<characterController>().enabled = false;
  41.             thirdCharacter.GetComponent<characterController>().enabled = false;
  42.         }
  43.        
  44.         if (Input.GetKeyDown(KeyCode.F3) && thirdIsEnabled == false) {
  45.             GetComponent<characterController>().enabled = false;
  46.             secondCharacter.GetComponent<characterController>().enabled = false;
  47.             thirdCharacter.GetComponent<characterController>().enabled = true;
  48.         }
  49.  
  50.         if (GetComponent<characterController>().enabled == true){
  51.             firstIsEnabled = true;
  52.         }
  53.  
  54.         if (GetComponent<characterController>().enabled == false){
  55.             firstIsEnabled = false;
  56.         }
  57.  
  58.         if (secondCharacter.GetComponent<characterController>().enabled == true){
  59.             secondIsEnabled = true;
  60.         }
  61.        
  62.         if (secondCharacter.GetComponent<characterController>().enabled == false){
  63.             secondIsEnabled = false;
  64.         }
  65.  
  66.         if (thirdCharacter.GetComponent<characterController>().enabled == true){
  67.             thirdIsEnabled = true;
  68.         }
  69.        
  70.         if (thirdCharacter.GetComponent<characterController>().enabled == false){
  71.             thirdIsEnabled = false;
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement