I am having issues with animating my character, my walk and idle animation work but the jogging (or run) animation doesnt play when I click shift but I know it works because I was debugging it before and it came up in console
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class animationStateController : MonoBehaviour
{
Animator animator;
int isWalkingHash;
int isRunningHash;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
isWalkingHash = Animator.StringToHash("isWalking");
isRunningHash = Animator.StringToHash("isRunning");
}
// Update is called once per frame
void Update()
{
bool isWalking = animator.GetBool(isWalkingHash);
bool forwardPressed = Input.GetKey("w");
bool isRunning = animator.GetBool(isRunningHash);
bool runPressed = Input.GetKey("left shift");
// Walking
if (!isWalking && forwardPressed)
{
animator.SetBool(isWalkingHash, true);
}
if (isWalking && !forwardPressed)
{
animator.SetBool(isWalkingHash, false);
}
// Running
if (!isRunning && (forwardPressed && runPressed))
{
animator.SetBool(isRunningHash, true);
}
if (!isRunning && (forwardPressed && !runPressed))
{
animator.SetBool(isRunningHash, false);
}
}
}
