From cef5e20697fe3e89d6e77e2195ed0ac796656094 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Fri, 15 Dec 2023 19:40:11 +0000
Subject: [PATCH] Added UI and health display
---
Assets/Scripts/PlayerController.cs | 44 ++++++++++++++++++++++++--------------------
1 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs
index b2d1868..4bf68d8 100644
--- a/Assets/Scripts/PlayerController.cs
+++ b/Assets/Scripts/PlayerController.cs
@@ -24,7 +24,7 @@
private set
{
_isMoving = value;
- animator.SetBool(AnimationStrings.Player.IsMoving, value);
+ animator.SetBool(AnimationStrings.Player.isMoving, value);
}
}
@@ -36,8 +36,8 @@
private set
{
_isFlying = value;
- animator.SetBool(AnimationStrings.Player.IsFlying, value);
- animator_rotor.SetBool(AnimationStrings.Player.IsFlying, value);
+ animator.SetBool(AnimationStrings.Player.isFlying, value);
+ animator_rotor.SetBool(AnimationStrings.Player.isFlying, value);
}
}
@@ -56,6 +56,14 @@
}
}
+ public bool CanMove { get
+ {
+ return animator.GetBool(AnimationStrings.canMove);
+ }
+ }
+
+
+
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
@@ -64,18 +72,6 @@
touchingDirections = GetComponent<TouchingDirections>();
}
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-
private void FixedUpdate()
{
if (moveInput.y == 0)
@@ -108,14 +104,22 @@
public void OnMove(InputAction.CallbackContext context)
{
- moveInput = context.ReadValue<Vector2>();
+ if (CanMove)
+ {
+ moveInput = context.ReadValue<Vector2>();
- IsMoving = moveInput.x != 0;
+ IsMoving = moveInput.x != 0;
- IsFlying = (moveInput.y != 0);
+ IsFlying = (moveInput.y != 0);
- SetFacingDirection(moveInput);
-
+ SetFacingDirection(moveInput);
+ }
+ else
+ {
+ IsMoving = false;
+ IsFlying = false;
+ moveInput = Vector2.zero;
+ }
}
private void SetFacingDirection(Vector2 moveInput)
--
Gitblit v1.10.0