Hey y’all, still new to this and any help will be much appreciated!
I’m trying to setup a door in my 2D platformer to be usable after the player has collected the 5 coins in my level.
Here’s my current script;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MoveScenes2D : MonoBehaviour
{
bool openDoor = false;
[SerializeField] private string newLevel;
void Update()
{
if(ScoreManager.score = 5)
{
openDoor = true;
}
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Player") && openDoor = true)
{
SceneManager.LoadScene(newLevel);
}
}
}
In ScoreManager, score is a public static int which tracks the number of coins collected. What am I doing wrong? D: