Hi!
I have made this WeaponSwitch script for my players in my game. When I try to switch weapon, it doesn’t appear. This has just been tested with secondary and primary weapon. There is no problem with the primary but when I switch to secondary, it doesn’t appear. It has the exact same properties as the primary one.
Here is my script:
void Start () {
primaryWeapon.SetActive(true);
secondaryWeapon.SetActive(false);
meeleWeapon.SetActive(false);
anim = GetComponent<Animator>();
}
void Update () {
if(slot > 1){
slot = 0;
}
if(slot < 0) {
slot = 1;
}
if(Input.GetAxis("Mouse ScrollWheel") < 0){
slot -= 1;
}
if(Input.GetAxis("Mouse ScrollWheel") > 0){
slot += 1;
}
if(slot == 0){
primaryWeapon.SetActive(true);
secondaryWeapon.SetActive(false);
meeleWeapon.SetActive(false);
}
if(slot == 1){
primaryWeapon.SetActive(false);
secondaryWeapon.SetActive(true);
meeleWeapon.SetActive(false);
}
if(slot == 2){
primaryWeapon.SetActive(false);
secondaryWeapon.SetActive(false);
meeleWeapon.SetActive(true);
}
}
If you know what the problem is, please tell me. Thanks.