35 lines
789 B
C#
35 lines
789 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using UnityEngine;
|
|
|
|
public class animationStateControler : MonoBehaviour
|
|
{
|
|
Animator animator;
|
|
int isWalkingHash;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
animator = GetComponent<animator>();
|
|
isWalkingHash = Animator.stringToHash("isWalking");
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
bool isWalking = animator.GetBool("isWalking");
|
|
bool forwardPressed = Input.GetKey('w');
|
|
if (!isWalking && forwardPressed)
|
|
{
|
|
animator.SetBool(isWalking, true);
|
|
}
|
|
if (isWalking && !forwardPressed)
|
|
{
|
|
animator.SetBool(isWalking, false);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|