2025-03-17 19:59:41 -04:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class HatRespawn : MonoBehaviour
|
|
|
|
|
{
|
2025-03-28 17:39:07 -04:00
|
|
|
void OnTriggerEnter2D(Collider2D collision) // Respawns the hat to the hat spawn position if it falls out of bounds
|
2025-03-17 19:59:41 -04:00
|
|
|
{
|
|
|
|
|
if (collision.gameObject.CompareTag("Platformer Hazard"))
|
|
|
|
|
{
|
|
|
|
|
transform.position = GameManager.Instance.hatSpawnPosition;
|
|
|
|
|
GetComponent<Rigidbody2D>().linearVelocity = Vector2.zero;
|
|
|
|
|
transform.rotation = Quaternion.identity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|