Hello guyz,
I'm trying to make a new action (for sure I will share it when is done) for changing Unity Animator variable. With this it can be possible to manage the animator with this.
I try my code but it's not working. There is my code:
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Animation)]
[Tooltip("Change a variable in the Unity Animator")]
public class AnimatorChangeVariable : FsmStateAction
{
[RequiredField]
[Tooltip("The name of animator variable to change.")]
public FsmString NameOfTheVariable;
private Animator anim; // Reference to the player's animator component.
private string FinalVariable;
public override void Reset()
{
NameOfTheVariable = "MyVariable";
}
public override void OnEnter()
{
FinalVariable = NameOfTheVariable.Value;
anim.SetBool(FinalVariable, true);
}
}
}
I tried using a name directly with the anim.SetBool command and it's not even worked. (anim.SetBool(Walk, true)
I didn't succeed to link the Animator Variable.
Can someone help me with my syntaxe please?