Problem with Unity updating player prefab over prefab instance
Hello everyone, I've been having issues with Unity only updating components from my player's prefab instead of the components in the instance of the player. For example, I have a script called Entity that stores the player's stats and name and such whenever stats get updated the instance is unaffected, but if I look at the prefab I can see the stat changes. Thanks in advance :).
public class EssentialsLoader : MonoBehaviour
{
// Start is called before the first frame update
public GameObject player;
void Awake()
{
if (PlayerController.instance == null) {
Instantiate(player);
}
}
// Update is called once per frame
void Update()
{
}
}
public class Entity : MonoBehaviour {
public new string name;
public int hp, attack, speed, defense, inteligence, stamina, mp;
[Space]
public int currentHP;
public int currentMP;
public int currentStamina;
public const int MaxHP = 9999;
public const int MaxAttack = 999;
public const int MaxSpeed = 999;
public const int MaxDefense = 9999;
public const int MaxInteligence = 999;
public const int MaxStamina = 9999;
public const int MaxMP = 9999;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
public class PlayerController : MonoBehaviour
{
public Rigidbody2D rb;
public float moveSpeed = 1f;
public Animator anim;
public static PlayerController instance;
public string areaTransitionID;
private Vector3 bottomLeftLimit;
private Vector3 topRightLimit;
public bool canMove = true;
// Start is called before the first frame update
void Start()
{
if (instance == null) {
instance = this;
}
else
{
if(instance != this)
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
}
}
Comment