Hi everyone, i have this problem and i need help.
I have this function that recives a integer and then changes a parameter in the animator
public void SetSkill(int index)
{
Debug.Log("Setting skill of " +gameObject.name + " with index "+index);
animator.SetInteger("Skill", index);
auxSkill = animator.GetInteger("Skill");
Debug.Log("Skill of " + gameObject.name +" is index "+animator.GetInteger("Skill"));
}
I created the variable ausxSkill just to see its value in the debugger. The problem is that inmediatly after changing the value of Skill it’s still 0.
If its’ helps, this is the function that calls SetSkills. I also added two logs before and after i call the function, so i’m sure that nothing happend after i use animator.SetInteger
public void GetRandomSkills()
{ // Debug.Log("start of fuinction, available skills: " + skills.Length);
int newSkill = Random.Range(1, skills.Length);
int newSkill2 = Random.Range(1, skills.Length);
SkillInfo newSkillInfo = new SkillInfo();
SkillInfo newSkillInfo2 = new SkillInfo();
newSkillInfo.skillBehaviour = skills[newSkill];
newSkillInfo.index = newSkill;
if (!turn)
{
availableSkillsPlayerOne[1] = newSkillInfo;
Debug.Log("setting skill 1");
skillImagesPlayerOne[1].SetSkill(availableSkillsPlayerOne[1].index);
Debug.Log("setting skill 1 ended");
newSkillInfo2.skillBehaviour = skills[newSkill2];
newSkillInfo2.index = newSkill2;
availableSkillsPlayerOne[2] = newSkillInfo;
skillImagesPlayerOne[2].SetSkill(availableSkillsPlayerOne[2].index);
}
}
This is the function SetSkill paused in the debugger, showing that animator.GetIntereger(“Skill”) although index value is 1.
This is the function where i call SetSkill()
And this are the logs showed in order.

The weird thing is, i created a button to call SetSkill directly instead of trhough another function and it works correctly, is only when is called in GetRandomSkills() that it fails.
Does anyone have any idea of what i may be doing wrong o what is going on? I apreciate any help i can get.
Edit: this is the code from the function called in the button. Is pretty simple, auxSkill it starts withe the value 0 and the idea is that every time i push the button it increases the value and call SetSkill(). Strangely, this way it works with no problem
public void ChangeSkill()
{
Debug.Log("calling from button");
auxSkill++;
SetSkill(auxSkill);
}
Here are the logs when i use the button. It gets the expected behaviour



