From 448b5092206ccd9db760b00aeb9ab2233270bd6e Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Fri, 15 Dec 2023 17:55:59 +0000
Subject: [PATCH] Added damageable script + death animations
---
Assets/Scripts/PlayerController.cs | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs
index c193afd..4bf68d8 100644
--- a/Assets/Scripts/PlayerController.cs
+++ b/Assets/Scripts/PlayerController.cs
@@ -14,6 +14,7 @@
Animator animator;
Animator animator_rotor;
public GameObject rotorGO;
+ TouchingDirections touchingDirections;
[SerializeField]
private bool _isMoving;
@@ -23,7 +24,7 @@
private set
{
_isMoving = value;
- animator.SetBool(AnimationStrings.Player.IsMoving, value);
+ animator.SetBool(AnimationStrings.Player.isMoving, value);
}
}
@@ -35,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);
}
}
@@ -55,23 +56,20 @@
}
}
+ public bool CanMove { get
+ {
+ return animator.GetBool(AnimationStrings.canMove);
+ }
+ }
+
+
+
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
animator_rotor = rotorGO.GetComponent<Animator>();
- }
-
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
+ touchingDirections = GetComponent<TouchingDirections>();
}
private void FixedUpdate()
@@ -106,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