Hello! So I recently followed a tutorial by Jimmy Vegas to make a collectable game object, from what i know, the code is correct and exactly as it is in the video, including the names. here’s the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoringSystem : MonoBehaviour
{
public GameObject scoreText;
public int theScore;
public AudioSource collectSound;
void OnTriggerEnter(Collider other)
{
collectSound.Play();
theScore += 50;
scoreText.GetComponent<Text>().text = "SCORE: " + theScore;
Destroy(gameObject);
}
}
My issue is that the game object that is being collected isnt being destroyed as it should be, neither is the sound playing, both game objects have colliders (Character controller and Box collider). I made sure the collider was set as a trigger and that the objects didnt have rigidbody. Im pretty lost right now, specially since this is for a project due tommorow, so help as fast as possible is appreciated. Thanks!