- Home /
How to i set the int to hitpoints / 10 + the current int.
I need to Set exp to h.hitPoints divided by 10 + the exp int * the level int.
code
while (h == null && hitTransform.parent) {
hitTransform = hitTransform.parent;
h = hitTransform.GetComponent<MonsterHealth> ();
}
if (h != null) {
if(h.tag != ("Player")){
h.GetComponent<PhotonView> ().RPC ("TakeDamage", PhotonTargets.All, damage);
PlayerPrefs.SetInt("Exp", h.hitPoints as int / 10 + PlayerPrefs.GetInt("Exp")* PlayerPrefs.Getint("Lvl"));
}
}
Comment
Best Answer
Answer by Codelyy · Jan 03, 2017 at 04:44 AM
Try
PlayerPrefs.SetInt("Exp", (int) h.hitPoints / 10 + PlayerPrefs.GetInt("Exp")* PlayerPrefs.Getint("Lvl"));
Are you resetting the variable somewhere else?
Also, I doubt this is needed but you could create a local variable before reassigning the "Exp" variable to hold the current Exp amount and then use that ins$$anonymous$$d of PlayerPrefs.GetInt("Exp"). Though again I doubt it's needed.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# divide float by integer 2 Answers
How do I create a save scene feature though int value in c# 2 Answers
Distribute terrain in zones 3 Answers