- Home /
 
 
               Question by 
               HamCoder404 · Aug 13, 2013 at 03:50 AM · 
                animationfpsweapondisappear  
              
 
              Multiple Weapon Animation Help
Ok, I am using a FPS kit on Unity and I'm trying to, well, make an FPS called Dear Hunting. I've ran in to some technical issues that are hard to explain, but basically every time I switch my weapon, the weapons disappear. Now I've noticed that the shadow shows that the guns are actually 180 degrees away from where they should be, which is weird... because they shouldn't. You can check out (I'd recommend downloading) my game USING THIS LINK. Any help or feedback would be appreciated! Thank you! This is the code that I have been using so far :
 var assaultRifle : GameObject;
 var pistol : GameObject;
 function Start(){
 //we want to define our first choice of weapon - this case will be the assault rifle
 assaultRifle.gameObject.SetActiveRecursively(false);
 pistol.gameObject.SetActiveRecursively(true);
 //this will deactivate the pistol and frag, and leave on the assault rifle
 }
 
 function SwitchWeapons(){
 if(assaultRifle.activeInHierarchy == false){
    if(Input.GetKeyDown("1")){
    //assault key
 
    animation.CrossFade("switchpistol1", 0.1);
    animation.CrossFade("switchsniper2", 0.1);
    killAll();
    assaultRifle.gameObject.SetActiveRecursively(true);
    }
 }
 
 if(assaultRifle.activeInHierarchy == true){
    if(Input.GetKeyDown("2")){
    //pistol key
 
    animation.CrossFade("switchsniper1", 0.1);
    animation.CrossFade("switchpistol2", 0.1);
    killAll();
    pistol.gameObject.SetActiveRecursively(true);
    }
 }
 }
  
 function killAll(){
    assaultRifle.gameObject.SetActiveRecursively(false);
    pistol.gameObject.SetActiveRecursively(false);
 }
 
 function Anime() {
 if (assaultRifle.activeInHierarchy == true) {
     if(Input.GetAxis("Vertical")){
         if(Input.GetKeyDown(KeyCode.LeftShift)){
             animation.CrossFade("sniperwalk1", 0.1);
         }
         else
         {
             animation.CrossFade("sniperwalk1", 0.1);
         }
     }
     else
     {
         animation.CrossFade("sniperidle1", 0.1);
     }
 }else
 if (pistol.activeInHierarchy == true) {
     if(Input.GetAxis("Vertical")){
         if(Input.GetKeyDown(KeyCode.LeftShift)){
             animation.CrossFade("pistolwalk1", 0.1);
         }
         else
         {
             animation.CrossFade("pistolwalk1", 0.1);
         }
     }
     else
     {
         animation.CrossFade("pistolidle1", 0.1);
     }
 }
 }
 
 function Update(){
 SwitchWeapons();
 Anime();
 }
 
               Any help or feedback would be appreciated! Thank you!
               Comment
              
 
               
              Your answer