From 1d74f3204692bb69aabf3c57fbdf4601a31a311f Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sat, 16 Dec 2023 18:32:11 +0000
Subject: [PATCH] Added audio manager + sound effects
---
Assets/Scripts/TouchingDirections.cs | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Assets/Scripts/TouchingDirections.cs b/Assets/Scripts/TouchingDirections.cs
index cbf8a60..4a26280 100644
--- a/Assets/Scripts/TouchingDirections.cs
+++ b/Assets/Scripts/TouchingDirections.cs
@@ -6,6 +6,10 @@
{
public ContactFilter2D castFilter;
public float groundDistance = 0.05f;
+ public float wallDistance = 0.2f;
+ public float ceilingDistance = 0.05f;
+
+ private Vector2 wallCheckDirection => gameObject.transform.localScale.x > 0 ? Vector2.right : Vector2.left;
Rigidbody2D rb;
public GameObject rotorGO;
@@ -15,6 +19,8 @@
Animator animator_rotor;
RaycastHit2D[] groundHits = new RaycastHit2D[5];
+ RaycastHit2D[] wallHits = new RaycastHit2D[5];
+ RaycastHit2D[] ceilingHits = new RaycastHit2D[5];
[SerializeField]
private bool _isGrounded;
@@ -25,11 +31,40 @@
set
{
_isGrounded = value;
- animator.SetBool(AnimationStrings.Player.IsGrounded, value);
- animator_rotor.SetBool(AnimationStrings.Player.IsGrounded, value);
+ animator.SetBool(AnimationStrings.Player.isGrounded, value);
+ animator_rotor.SetBool(AnimationStrings.Player.isGrounded, value);
}
}
+ [SerializeField]
+ private bool _isAtWall;
+
+ public bool IsAtWall
+ {
+ get { return _isAtWall; }
+ set
+ {
+ _isAtWall = value;
+ animator.SetBool(AnimationStrings.Player.isAtWall, value);
+ animator_rotor.SetBool(AnimationStrings.Player.isAtWall, value);
+ }
+ }
+
+ [SerializeField]
+ private bool _isAtCeiling;
+
+ public bool IsAtCeiling
+ {
+ get { return _isAtCeiling; }
+ set
+ {
+ _isAtCeiling = value;
+ animator.SetBool(AnimationStrings.Player.isAtCeiling, value);
+ animator_rotor.SetBool(AnimationStrings.Player.isAtCeiling, value);
+ }
+ }
+
+
void Awake()
{
@@ -47,5 +82,7 @@
void FixedUpdate()
{
IsGrounded = touchingCol.Cast(Vector2.down, castFilter, groundHits, groundDistance) > 0;
+ IsAtWall = touchingCol.Cast(wallCheckDirection, castFilter, wallHits, wallDistance) > 0;
+ IsAtCeiling = touchingCol.Cast(Vector2.up, castFilter, ceilingHits, ceilingDistance) > 0;
}
}
--
Gitblit v1.10.0