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

How to save different values with same script?

$
0
0
Hello i am making a coockie clicker like game were there is a shop and you can buy different items. I have 2 scripts one for items that add per secound and one that adds a multipler. I have made it so the price increases when i buy items and it works but when im trying to save and load all the items with the same script cost the same the script: public class SlapModifier : MonoBehaviour { public Text CostT; public float Cost; public int modifier; void Start() { Cost = PlayerPrefs.GetFloat("newcostmod"); } public void Update() { CostT.text = "Cost: " + Cost.ToString("F0"); PlayerPrefs.SetFloat("newcostmod", Cost); } public void Buy() { GameObject gamemanager = GameObject.Find("GameManager"); gameManager gamemanagersc = gamemanager.GetComponent(); if(gamemanagersc.currSlaps >= Cost) { gamemanagersc.currSlaps -= Cost; gamemanagersc.slapModifier += modifier; Cost *= 1.25f; } } }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



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