I am working more on my door system for my puzzle game, and I am using an int value to relate to the number of puzzles in the level to determine wether or not the door should open, however, I am having some trouble figuring out how to keep the puzzle visibly solved as well as only allowing the int value to increase by 1 for each solved puzzle, here is the code I have as of right now, all help is apreciated!
using UnityEngine;
public class SwitchActivation : MonoBehaviour
{
public Rigidbody2D rb;
Rigidbody2D m_Rigidbody;
public int puzzlecomplete = 0;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
m_Rigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (rb.position == m_Rigidbody.position)
{
puzzlecomplete += 1;
Debug.Log($"puzzlecomplete = {puzzlecomplete}");
}
}
}