using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed;
private Animator anim;
private bool playerMoveing;
private Vector2 lastMove;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
playerMoveing = false;
if (Input.GetAxisRaw("Horizontal") >0.5f || Input.GetAxisRaw("Horizontal") <-0.5f)
{
transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
playerMoveing = true;
lastMove=new Vector2 (Input.GetAxisRaw("Horizontal"),0f);
}
if (Input.GetAxisRaw("Vertical") >0.5f || Input.GetAxisRaw("Vertical") <-0.5f)
{
transform.Translate(new Vector3(0f, Input.GetAxisRaw("Vertical") * moveSpeed * Time.deltaTime, 0f));
playerMoveing = true;
lastMove = new Vector2(0f, Input.GetAxisRaw("Vertical"));
{
anim.SetFloat("MoveX", Input.GetAxisRaw("Horizontal"));
anim.SetFloat("MoveY", Input.GetAxisRaw("Vertical"));
anim.SetBool("PlayerMoveing", playerMoveing);
anim.SetFloat("LastMoveX", lastMove.x);
anim.SetFloat("LastMoveY", lastMove.y);
}