player walk animation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Character : MonoBehaviour
|
||||
public abstract class Character : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
protected Animator _animator;
|
||||
@@ -65,7 +65,7 @@ public class Character : MonoBehaviour
|
||||
FlipCharacter();
|
||||
}
|
||||
|
||||
//animator.SetBool("Walk", h_movement != 0);
|
||||
SetWalkingAnimation(h_movement != 0);
|
||||
|
||||
_isOnLadder = mapElement == MapElementType.Ladder || GetMapElement(Vector2.up) == MapElementType.Ladder;
|
||||
if (_isOnLadder)
|
||||
@@ -105,6 +105,7 @@ public class Character : MonoBehaviour
|
||||
return MapElementType.Empty;
|
||||
}
|
||||
|
||||
protected abstract void SetWalkingAnimation(bool isWalking);
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
@@ -119,7 +120,7 @@ public class Character : MonoBehaviour
|
||||
if (_isFalling)
|
||||
{
|
||||
_body.velocity = new Vector2(0, _body.velocity.y);
|
||||
//animator.SetBool("Walk", false);
|
||||
SetWalkingAnimation(false);
|
||||
|
||||
if (GetMapElement(Vector2.down)==MapElementType.Ladder)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,10 @@ using UnityEngine;
|
||||
|
||||
public class EnemyAI : Character
|
||||
{
|
||||
protected override void SetWalkingAnimation(bool isWalking)
|
||||
{
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float horizontal = 0;
|
||||
|
||||
@@ -87,4 +87,10 @@ public class Player : Character
|
||||
_hammer.transform.localScale = new Vector2(_hammer.transform.localScale.x * (_facingRight ? 1 : -1), _hammer.transform.localScale.y);
|
||||
_hammer.GetComponent<Rigidbody2D>().velocity = new Vector2(gameObject.transform.localScale.x * _hammerSpeed, 0);
|
||||
}
|
||||
|
||||
protected override void SetWalkingAnimation(bool isWalking)
|
||||
{
|
||||
_animator.SetBool("Legs_Walk",isWalking);
|
||||
_animator.SetBool("Body_Walk", isWalking);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user