- Home /
Question by
Tramplex · Sep 11, 2017 at 09:02 AM ·
animatoranimator controllerboolstate-machine
Bool in animator is not changing state
I have this code that should change states when i equip smtng
public void EquipItem(int equipmentSlot){
if (inventory [uimanager.activeItemInInventory].type == ItemInInventory.Type.Weapon) {
if (selectedSlot != 0 && !string.IsNullOrEmpty (equipment [equipmentSlot].itemName)) {
print ("was equiped " + equipment [equipmentSlot].itemName);
playerControls.anim.SetBool ("idle" + equipment [selectedSlot].itemName, false);
playerControls.anim.SetBool ("default", true);
inventory [inventory.IndexOf (equipment [equipmentSlot])].isEquiped = false;
Destroy (GameObject.Find (equipment [selectedSlot].itemName + "ToEquip"));
} else if (selectedSlot == 0) {
print ("was hands");
playerControls.anim.SetBool ("idlehands", false);
playerControls.anim.SetBool ("default", true);
}
inventory [uimanager.activeItemInInventory].isEquiped = true;
equipment [equipmentSlot] = inventory [uimanager.activeItemInInventory];
selectedSlot = equipmentSlot;
playerControls.anim.SetBool ("default", false);
playerControls.anim.SetBool ("idle" + equipment [selectedSlot].itemName, true);
print ("idle" + equipment [selectedSlot].itemName);
playerControls.selectedWeapon = equipment [selectedSlot];
GameObject instance = Instantiate (Resources.Load<GameObject> ("ToEquip/" + equipment [equipmentSlot].itemName + "ToEquip"), inHandHolder.transform.position, inHandHolder.transform.rotation, inHandHolder.transform);
instance.name = instance.name.Replace ("(Clone)", "").Trim ();
uimanager.EnterInventory (uimanager.pageOfInventory);
uimanager.EnterItemInInventoryDescriptyion ();
} else if (inventory [uimanager.activeItemInInventory].type == ItemInInventory.Type.Clothes) {
}
}
When i equip axe, animator state i getting stuck on default state and not changing to idleFireaxe. In console i see that it prints "was hands" and then "idleFireaxe" but state is still default. Also if i manually change bool idleFireaxe to true it sets state to idleFireaxe and then working well on other transitions ( to "aimFireaxe" and "hitFireaxe"). https://imgur.com/a/K2VMl What can i do with this thing?? someone help, please , i feel so desperate (
Comment