Hi all,
I’m new to coding and have come across a problem I dont understand. I made a script for collecting an object and gaining a score from it. That part works fine. But I’d like it to update so that when the score equals a certain amount, my in game scene will change to my win scene. I’ve tried (see below) but it doesn’t seem to be working. Although no errors come up. Any help is much appreciated:) Screenshot included too
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.SceneManagement;
///
/// This script allows player to collect hearts and gain score
///
public class CollectHeart : MonoBehaviour
{
public AudioSource collectSound;
void OnTriggerEnter(Collider other)
{
collectSound.Play();
ScoringSystem.theScore += 10;
Destroy(gameObject);
}
public void Update()
{
if (ScoringSystem.theScore == 60)
{
SceneManager.LoadScene(“winScene”);
}
}
}