The walking animation hasn’t been working for me for a while, but having got through the course I’ve decided to go back and figure out what’s wrong, and I’m going crazy.
From what I can tell from the animator, the transition from Rifle Aiming Idle to Rifle Run is not working - the idle animation continues to play while the unit moves. It worked fine before the UnitAnimator script was created.
From UnitAnimator:
private void Awake()
{
if (TryGetComponent<MoveAction>(out MoveAction moveAction))
{
moveAction.OnStartMoving += MoveAction_OnStartMoving;
moveAction.OnStartMoving += MoveAction_OnStopMoving;
moveAction.OnChangedFloorsStarted += MoveAction_OnChangedFloorsStarted;
}
// later
private void MoveAction_OnStartMoving(object sender, EventArgs e)
{
animator.SetBool("IsWalking", true);
}
private void MoveAction_OnStopMoving(object sender, EventArgs e)
{
animator.SetBool("IsWalking", false);
}
So I’m sure the string matches just fine. I’ve also run a debug.log to check MoveAction_OnStartMoving is firing, and it is. The Jump and Drop animations from the bonus multifloor section of this course also work from within this script, as does the shoot animation.
I’ve tried placing the UnitAnimator in various places in project settings script execution order, and it makes no difference.
Here’s the relevant parts of the MoveAction script:
public event EventHandler OnStartMoving;
public event EventHandler OnStopMoving;
// later
public override void TakeAction(GridPosition gridPosition, Action onActionComplete)
{
List<GridPosition> pathGridPositionList = Pathfinding.Instance.FindPath(unit.GetGridPosition(), gridPosition, out int pathLength);
currentPositionIndex = 0;
positionList = new List<Vector3>();
foreach (GridPosition pathGridPosition in pathGridPositionList)
{
positionList.Add(LevelGrid.Instance.GetWorldPosition(pathGridPosition));
}
OnStartMoving?.Invoke(this, EventArgs.Empty);
ActionStart(onActionComplete);
}
Any idea as to what is going wrong?