Update hat movement
This commit is contained in:
@@ -20,7 +20,7 @@ public class GameManager : MonoBehaviour
|
||||
public static GameMode gameMode = GameMode.freeForAll; // loads a default gamemode as a safety net
|
||||
public static string map = "Platformer With Headroom"; // loads a default map as a safety net
|
||||
public Vector2 spawnPosition;
|
||||
public Vector2 hatSpawnPosition;
|
||||
public List<Vector2> hatSpawnPositions = new List<Vector2>();
|
||||
public Canvas LeaderboardCanvas;
|
||||
public Canvas TimerCanvas;
|
||||
public GameObject hatObject;
|
||||
|
||||
@@ -6,10 +6,13 @@ public class HatRespawn : MonoBehaviour
|
||||
private const float respawnTime = 10f;
|
||||
private bool isDropped;
|
||||
|
||||
public static bool canBePickedUp = true; // Flag to check if the hat can be picked up
|
||||
|
||||
void Start()
|
||||
{
|
||||
lastInteractionTime = Time.time;
|
||||
isDropped = false;
|
||||
transform.position = GameManager.Instance.hatSpawnPositions[Random.Range(0, GameManager.Instance.hatSpawnPositions.Count - 1)];
|
||||
}
|
||||
|
||||
void Update() // Checks if the hat has been inactive for too long
|
||||
@@ -42,8 +45,9 @@ public class HatRespawn : MonoBehaviour
|
||||
|
||||
private void RespawnHat() // Respawns the hat at the designated spawn position
|
||||
{
|
||||
transform.position = GameManager.Instance.hatSpawnPosition;
|
||||
transform.position = GameManager.Instance.hatSpawnPositions[Random.Range(0, GameManager.Instance.hatSpawnPositions.Count - 1)];
|
||||
GetComponent<Rigidbody2D>().linearVelocity = Vector2.zero;
|
||||
GetComponent<Rigidbody2D>().angularVelocity = 0f;
|
||||
transform.rotation = Quaternion.identity;
|
||||
lastInteractionTime = Time.time; // Reset the timer after respawning
|
||||
isDropped = false;
|
||||
|
||||
Reference in New Issue
Block a user