I have coins in my game as collectibles and Id like the coins to not come back after the character respawns/ the scene reloads
Ive found some forum posts regarding the topic but theyre all on the topic of more complex enemy controllers, Im just looking to make the "destroy gameobject" function last after scenes reload/change, any advice appreciated 🙂
public class Coin : MonoBehaviour
{
public int value;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Player"))
{
SoundManagerScript.PlaySound("pickup"); // PLAYS SOUND
Destroy(gameObject);
CoinCounter.instance.IncreaseCoins(value);
}
}
}
code for the coin^^