Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: JavaScript  |  size: 2.46 KB  |  hits: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. var lPunch : boolean = false;
  3. var rPunch: boolean = false;
  4. var lKick : boolean = false;
  5. var rKick: boolean = false;
  6. var inAnim : boolean = false;
  7. var ready : boolean = true;
  8. function Awake(){
  9.        
  10.         var p1Lshoulder = gameObject.FindWithTag("P1LShoulder").transform;
  11.         gameObject.animation["LeftJab"].AddMixingTransform(p1Lshoulder);
  12.         animation["LeftJab"].layer = 1;
  13.  
  14.         var p1Rshoulder = gameObject.FindWithTag("P1RShoulder").transform;
  15.         animation["RightJab"].AddMixingTransform(p1Rshoulder);
  16.         animation["RightJab"].layer = 1;
  17.        
  18.         var p1Lthigh = gameObject.FindWithTag("P1LThigh").transform;
  19.         animation["LeftKick"].AddMixingTransform(p1Lthigh);
  20.         animation["LeftKick"].layer = 1;
  21.        
  22.         var p1Rthigh = gameObject.FindWithTag("P1RThigh").transform;
  23.         animation["RightKick"].AddMixingTransform(p1Rthigh);
  24.         animation["RightKick"].layer = 1;
  25.        
  26.         animation.CrossFade("idle");
  27. }
  28.  
  29. function Update () {
  30.        
  31.         //LeftPunch-
  32.         if(Input.GetButtonDown("Button1")){
  33.                 if(ready){
  34.                         lPunch=true;
  35.                         ready = false;
  36.                         animation.CrossFadeQueued("LeftJab",.1F,QueueMode.CompleteOthers);
  37.                         //animation.Play("LeftJab");
  38.                 }
  39.         }else if(Input.GetButtonUp("Button1")){
  40.                 ready = true;
  41.         }
  42.         if(lPunch &&!animation.IsPlaying("LeftJab")){
  43.                 animation.CrossFadeQueued("idle",0.01F,QueueMode.CompleteOthers);
  44.                 lPunch = false;
  45.         }
  46.  
  47.         //RightPunch-
  48.         if(Input.GetButtonDown("Button2")){
  49.                 if(ready){
  50.                         rPunch = true;
  51.                         ready = false;
  52.                         animation.CrossFadeQueued("RightJab",.09F,QueueMode.CompleteOthers);
  53.                 }
  54.         }else if(Input.GetButtonUp("Button2")){
  55.                 ready =true;
  56.         }
  57.        
  58.         if(rPunch &&!animation.IsPlaying("RightJab")){
  59.                 animation.CrossFadeQueued("idle",0.5F,QueueMode.CompleteOthers);
  60.                 rPunch = false;
  61.         }
  62.        
  63.         //LeftKick-
  64.         if(Input.GetButtonDown("Button3")){
  65.                 if(ready){
  66.                         rKick = true;
  67.                         ready = false;
  68.                         animation.CrossFadeQueued("LeftKick",.01F,QueueMode.CompleteOthers);
  69.                 }
  70.         }else if(Input.GetButtonUp("Button3")){
  71.                 ready =true;
  72.         }
  73.        
  74.         if(lKick &&!animation.IsPlaying("LeftKick")){
  75.                 animation.CrossFadeQueued("idle",1F,QueueMode.CompleteOthers);
  76.                 lKick = false;
  77.         }
  78.        
  79.         //RightKick-
  80.         if(Input.GetButtonDown("Button4")){
  81.        
  82.                 if(ready){
  83.                         lKick = true;
  84.                         ready = false;
  85.                         animation.CrossFadeQueued("RightKick",0.2F,QueueMode.CompleteOthers);
  86.                 }
  87.         }else if(Input.GetButtonUp("Button4")){
  88.                 ready =true;
  89.         }
  90.        
  91.         if(rKick &&!animation.IsPlaying("RightKick")){
  92.                 animation.CrossFadeQueued("idle",0.01F,QueueMode.CompleteOthers);
  93.                 rKick = false;
  94.         }
  95.        
  96.        
  97.        
  98. }