Guest User

unity bad scripting

a guest
Aug 18th, 2015
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.56 KB | None | 0 0
  1. void Start()
  2.     {
  3.         Cursor.lockState = CursorLockMode.Locked;
  4.         Head = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 Head");
  5.         Neck = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck");
  6.  
  7.  
  8.         RightUpperHand = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm");
  9.         RightForearm = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm");
  10.         RightHand = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand");
  11.  
  12.          LeftUpperHand = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 L Clavicle/Bip01 L UpperArm");
  13.          LeftForearm = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm");
  14.          LeftHand = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand");
  15.  
  16.         weapon = transform.Find ("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/pistol_glock");
  17.        
  18.         GetComponent<Animation>()["stand_pistol"].AddMixingTransform(LeftUpperHand);
  19.         GetComponent<Animation>()["stand_pistol"].AddMixingTransform(RightUpperHand);
  20.         GetComponent<Animation>()["stand_pistol"].layer = 10;
  21.         GetComponent<Animation>()["stand_pistol"].enabled = true;
  22.         GetComponent<Animation>()["stand_pistol"].weight = 1.0f;
  23.         GetComponent<Animation>()["stand_pistol"].wrapMode = WrapMode.ClampForever;
  24.         GetComponent<Animation>()["reload_pistol"].AddMixingTransform(LeftUpperHand);
  25.         GetComponent<Animation>()["reload_pistol"].AddMixingTransform(RightUpperHand);
  26.         GetComponent<Animation>()["reload_pistol"].layer = 10;
  27.         GetComponent<Animation>()["reload_pistol"].weight = 1.0f;
  28.         GetComponent<Animation>()["reload_pistol"].speed = 0.25f;
  29.         GetComponent<Animation>()["pda_pistol"].AddMixingTransform(LeftUpperHand);
  30.         GetComponent<Animation>()["pda_pistol"].AddMixingTransform(RightUpperHand);
  31.         GetComponent<Animation>()["pda_pistol"].layer = 10;
  32.         GetComponent<Animation>()["pda_pistol"].weight = 1.0f;
  33.         GetComponent<Animation>()["pda_pistol"].speed = 0.25f;
  34.     }
  35.  
  36.     void Update()
  37.     {
  38.        
  39.         if (Input.GetKey(KeyCode.W))
  40.         {
  41.             if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
  42.             {
  43.                 GetComponent<Animation>()["walk_forward"].speed = 2.5f;
  44.             }
  45.             else
  46.             {
  47.                 GetComponent<Animation>()["walk_forward"].speed = 1.5f;
  48.             }
  49.  
  50.             if (!GetComponent<Animation>().IsPlaying("walk_forward"))
  51.             {
  52.                 GetComponent<Animation>().CrossFade("walk_forward");
  53.             }
  54.            
  55.         }
  56.         else if (Input.GetKey(KeyCode.A))
  57.         {
  58.             if (!GetComponent<Animation>().IsPlaying("walk_left"))
  59.             {
  60.                 GetComponent<Animation>().CrossFade("walk_left");
  61.             }
  62.  
  63.         }
  64.         else if (Input.GetKey(KeyCode.D))
  65.         {
  66.             if (!GetComponent<Animation>().IsPlaying("walk_right"))
  67.             {
  68.                 GetComponent<Animation>().CrossFade("walk_right");
  69.             }
  70.  
  71.         }
  72.         else if (Input.GetKey(KeyCode.S))
  73.         {
  74.             GetComponent<Animation>()["walk_forward"].speed = -1.5f;
  75.             if (!GetComponent<Animation>().IsPlaying("walk_forward"))
  76.             {
  77.                 GetComponent<Animation>().CrossFade("walk_forward");
  78.             }
  79.  
  80.         }
  81.        
  82.         if ((reload)&&(!GetComponent<Animation>().IsPlaying("reload_pistol")))
  83.         {
  84.             reload = false;
  85.         }
  86.         if ((!reload)&&(!pda))
  87.         {
  88.             GetComponent<Animation>().Play("stand_pistol");
  89.             if (Input.GetKey(KeyCode.R))
  90.             {
  91.                 reload = true;
  92.                 GetComponent<Animation>().Play("reload_pistol");
  93.             }
  94.             if (Input.GetKey(KeyCode.F))
  95.             {
  96.                 pda = true;
  97.                 GetComponent<Animation>().Play("pda_pistol");
  98.             }
  99.         }
  100.  
  101.         if ((pda) && (!GetComponent<Animation>().IsPlaying("pda_pistol")))
  102.         {
  103.             pda = false;
  104.         }
  105.         if (((Input.GetKey(KeyCode.F))) && (GetComponent<Animation>()["pda_pistol"].normalizedTime > 0.45f))
  106.         {
  107.             GetComponent<Animation>()["pda_pistol"].normalizedTime = 0.46f;
  108.         }
  109.  
  110.  
  111.     }
Advertisement
Add Comment
Please, Sign In to add comment