I'm trying to keep currentHealth variable the same when switching to another level by using DontDestroyOnLoad()
public class Health : MonoBehaviour
{
[SerializeField] public float startingHealth;
public float currentHealth;
private void Awake()
{
currentHealth = startingHealth;
GameObject.DontDestroyOnLoad(this.currentHealth);
}
but I'm facing with this error Argument 1: cannot convert from 'float' to 'UnityEngine.Object'
I'm new to Unity and I don't know how to use this method properly. Thank you in advance.