bug fixes

This commit is contained in:
djkellerman
2025-03-28 23:07:33 -04:00
parent c7b1e55a3e
commit af8ea44fe1
3 changed files with 9 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ public class HatRespawn : MonoBehaviour
{ {
if (isDropped && Time.time - lastInteractionTime > respawnTime) if (isDropped && Time.time - lastInteractionTime > respawnTime)
{ {
Debug.Log("Hat has been inactive for too long. Respawning...");
RespawnHat(); RespawnHat();
} }
} }
@@ -24,6 +25,7 @@ public class HatRespawn : MonoBehaviour
{ {
if (collision.gameObject.CompareTag("Platformer Hazard")) if (collision.gameObject.CompareTag("Platformer Hazard"))
{ {
Debug.Log("Hat collided with Platformer Hazard. Respawning...");
RespawnHat(); RespawnHat();
} }
} }
@@ -32,12 +34,14 @@ public class HatRespawn : MonoBehaviour
{ {
lastInteractionTime = Time.time; lastInteractionTime = Time.time;
isDropped = false; isDropped = false;
Debug.Log("Hat interacted with. Resetting timer.");
} }
public void OnHatDropped() // Resets the timer when the hat is dropped public void OnHatDropped() // Resets the timer when the hat is dropped
{ {
lastInteractionTime = Time.time; lastInteractionTime = Time.time;
isDropped = true; isDropped = true;
Debug.Log("Hat dropped. Starting respawn timer.");
} }
private void RespawnHat() // Respawns the hat at the designated spawn position private void RespawnHat() // Respawns the hat at the designated spawn position
@@ -47,5 +51,6 @@ public class HatRespawn : MonoBehaviour
transform.rotation = Quaternion.identity; transform.rotation = Quaternion.identity;
lastInteractionTime = Time.time; // Reset the timer after respawning lastInteractionTime = Time.time; // Reset the timer after respawning
isDropped = false; isDropped = false;
Debug.Log("Hat respawned at designated position.");
} }
} }

View File

@@ -40,7 +40,7 @@ public class Damageable : MonoBehaviour
private void Damage(GameObject damageSource) // Damages player private void Damage(GameObject damageSource) // Damages player
{ {
if (dying) return; if (dying || damageSource.CompareTag("Hat")) return; // Exclude hat from taking damage
float actualForce = damageSource.GetComponent<Damageable>().force; float actualForce = damageSource.GetComponent<Damageable>().force;
Block blockComponent = GetComponent<Block>(); Block blockComponent = GetComponent<Block>();
@@ -106,7 +106,6 @@ public class Damageable : MonoBehaviour
} }
} }
public void HandleDeath() // Removes player from dying state after respawn public void HandleDeath() // Removes player from dying state after respawn
{ {
GameManager.Instance.PlayerDied(this); GameManager.Instance.PlayerDied(this);

View File

@@ -61,6 +61,7 @@ public class UseItem : MonoBehaviour
heldItem.GetComponent<Collider2D>().enabled = true; heldItem.GetComponent<Collider2D>().enabled = true;
heldItem.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; heldItem.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
heldItem.transform.position += Vector3.up * 3f; heldItem.transform.position += Vector3.up * 3f;
heldItem.GetComponent<HatRespawn>().OnHatDropped();
heldItem = null; heldItem = null;
isHoldingItem = false; isHoldingItem = false;
if (GameManager.playerHoldTimes.ContainsKey(gameObject)) if (GameManager.playerHoldTimes.ContainsKey(gameObject))
@@ -69,4 +70,5 @@ public class UseItem : MonoBehaviour
} }
} }
} }
} }