- Home /
Points system doesn't work
So I'm using corgi engine to make a platforming game. And something weird happened. This is my code:
using System.Collections;
using System.Collections.Generic;
using MoreMountains.CorgiEngine;
using UnityEngine;
public class EnableOnPoints : MonoBehaviour
{
[SerializeField] GameManager gameManager;
[SerializeField] GameObject gate;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
int currentPoints = gameManager.Points;
if(currentPoints >= 60) {
gate.SetActive(true);
}
}
}
The problem is this logic works only when you load the scene separately... Like this code is for level 4 and if you loaded that level separately it would work but if you finished level 3 and went to level 4 it wouldn't work...
And I have no clue what the problem is. Any help would be reaaaally appreciated.
Edit: I just realized this was happening because the "Game Managers" Game object which contained the "Game manager" script was using a singleton pattern from the previous levels so I changed the code to this: using System.Collections; using System.Collections.Generic; using MoreMountains.CorgiEngine; using UnityEngine;
public class EnableOnPoints : MonoBehaviour
{
GameManager gameManager;
[SerializeField] GameObject gate;
// Start is called before the first frame update
void Start()
{
gameManager = FindObjectOfType<GameManager>();
}
// Update is called once per frame
void Update()
{
int currentPoints = gameManager.Points;
if(currentPoints >= 60) {
gate.SetActive(true);
}
}
}
But still, the exact same thing happens :(( please help...
Your answer
Follow this Question
Related Questions
Help with different medals for completing a level 1 Answer
help please: Level Changing Scipt 1 Answer
What to consider for changing environment, using enable/disabled or new scene? 2 Answers
Single scene, multiple levels 1 Answer
Loading Screen? 6 Answers