Answer the question
In order to leave comments, you need to log in
Why is the shift not getting data from another script?
The script should remove the cost of the skin from the player's account, but as a result, nothing happens.
The function that should withdraw money:
void Update ()
{
if (oppAcc == true) {
if (playerInfo.gold >= mfb && playerInfo.crystals >= cfb)
{
playerInfo.gold = playerInfo.gold - mfb;
playerInfo.skin = buttonClickedOnObjectForBuy;
playerInfo.crystals = playerInfo.crystals - cfb;
}
if (playerInfo.gold < mfb || playerInfo.crystals < cfb)
{
playerInfo.skin = 999;
}
}
}
public class PlayerInfo : MonoBehaviour {
public int skin;
public int weapon;
public int gold ;
public int crystals ;
public int swords;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
gold = 10000;
crystals = 10000;
}
}
Answer the question
In order to leave comments, you need to log in
When you write code like this, a kitten dies somewhere in the world, don't be a monster!
you can just
and what is oopAcc? What is mfb, cfb? Write properly.
Why skin 999? What is 999? id? Why not enum? Okay, these are the little things. What does this purchase code do in update? Reading the documentation https://docs.unity3d.com/ScriptReference/MonoBehav... update is called every frame, you will buy a lot of things while the oppAcc variable is true. Also what does this code do in update?
void Update () {
gold = 10000;
crystals = 10000;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question