2DAdventureGit/Assets/Scripts/Player/PlayerAnimation.cs

31 lines
689 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimation : MonoBehaviour
{
private Animator anim;
private Rigidbody2D rb;
private PhysicsCheck physicsCheck;
private void Awake()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
physicsCheck = GetComponent<PhysicsCheck>();
}
private void Update()
{
SetAnimation();
}
private void SetAnimation()
{
anim.SetFloat("velocityX", Mathf.Abs(rb.velocity.x));
anim.SetFloat("velocityY", rb.velocity.y);
anim.SetBool("isGround", physicsCheck.isGround);
}
}