In Unity 3D I am attempting to make transitions between character movement animations that get activated by pressing specific keys. I am following a tutorial here so I can refer to it in order to double check for code misspellings or mistakes in animation editor, yet I find nothing that isn't done in the tutorial. So I am asking for help in figuring out what is wrong as I am coming up blank.
2 warnings that keep appearing continuosly
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationState : 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 isrunning = animator.GetBool(isRunningHash);
bool isWalking = animator.GetBool(isWalkingHash);
bool forwardPressed = Input.GetKey("w");
bool runPressed = Input.GetKey("left shift");
if (!isWalking && forwardPressed)
{
animator.SetBool(isWalkingHash, true);
}
if (isWalking && !forwardPressed)
{
animator.SetBool(isWalkingHash, false);
}
if (!isrunning && (forwardPressed && runPressed))
{
animator.SetBool(isRunningHash, true);
}
if (isrunning && (!forwardPressed || !runPressed))
{
animator.SetBool(isRunningHash, false);
}
}
}