Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Is this a good way of resetting stats?

$
0
0
private void Awake() { currentHealth = startingHealth; movement = GetComponent(); points = PlayerPrefs.GetInt("Points", 0); currentHealth = PlayerPrefs.GetInt("Health", startingHealth); movement.extraJumpValue = PlayerPrefs.GetInt("JumpThree", movement.extraJumpValue); movement.jumpForce = PlayerPrefs.GetFloat("JumpHeight", movement.jumpForce); movement.speed = PlayerPrefs.GetFloat("PlayerSpeed", movement.speed); } public void ResetStats() { PlayerPrefs.SetInt("Points", points); PlayerPrefs.SetInt("Health", 100); PlayerPrefs.SetInt("JumpThree", 1); PlayerPrefs.SetFloat("JumpHeight", 5); PlayerPrefs.SetFloat("PlayerSpeed", 3); } private void OnDestroy() { PlayerPrefs.SetInt("Points", points); PlayerPrefs.SetInt("Health", currentHealth); PlayerPrefs.SetInt("JumpThree", movement.extraJumpValue); PlayerPrefs.SetFloat("JumpHeight", movement.jumpForce); PlayerPrefs.SetFloat("PlayerSpeed", movement.speed); }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>