I want my object to delete if it has already been picked up the next time the game starts.
Am i doing this right ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class KeySave : MonoBehaviour {
public int got;
public void awake (){
got = PlayerPrefs.GetInt ("Key");
if (PlayerPrefs.GetInt ("Key") == 1)
Object.Destroy (gameObject);
}
public void OnTriggerEnter2D(Collider2D other){
if (other.tag == "Player") {
PlayerPrefs.SetInt("key", 1);
PlayerPrefs.Save ();
}
}
}