Weapon Swap loop only one way. Any ideas?
Can you check this piece of code and tell me where i am doing wrong? it suppose to be two way code. from equipment screen to inventory works fine but from inventory screen to equiptment screen when i swap, the instantiation works then destroys the instantiated object.. ui system is working fine they swap the sprites both ways but not the gameobjects related to those sprites. probably i am looping the code somehow. i checked by log numbers and patterns are not looping. no item on equipment system : 1,2 from equipment screen to imventory screen : 4,5,2,3, from invetory screen to equiptment screen : 4,5,2,3,4,5 getting mad at this code. working on it for 2 days and i am sure i cant see the obvious error.
void EquipWeapon(Item item)
{
if (item.itemType == ItemType.Weapon)
{
if (EquipedWeapon != null)
{
Debug.Log("log1");
Destroy(EquipedWeapon);
}
EquipedWeapon = (GameObject)Instantiate(item.itemModel, playerHand.transform.position, playerHand.transform.rotation);
EquipedWeapon.transform.SetParent(playerHand.transform);
Debug.Log("log2");
if (HPMANACanvas != null)
{
UpdateManaBar();
UpdateHPBar();
Debug.Log("Log3");
}
}
}
void UnEquipWeapon(Item item)
{
if (item.itemType == ItemType.Weapon)
{
Debug.Log("Log4");
Destroy(EquipedWeapon);
EquipedWeapon = null;
if (HPMANACanvas != null)
{
UpdateManaBar();
UpdateHPBar();
Debug.Log("Log5");
}
}
}
Your answer
Follow this Question
Related Questions
Help with Script 0 Answers
Parse issue, despite the data being pulled from database 2 Answers
c# - error CS0103: The name `hit' does not exist in the current context (cardboard switching) 1 Answer
Errors in script when trying to play animation clips 1 Answer
Having trouble deleting objects from a list after they reach a certain scale. 0 Answers