In Game Shop System (Use and Buy Problems) Help!!!!!!!!
the problem is that when a person buys a ship and leaves the tent scene, if reenters have to buy the ship back that's the problem!
what I do is that when the user has enough money and touch the button to buy this disappears and aparace the button to use and sends it to the scene of the other ship, but if you re-enter the store the script is renewed which causes the button use disappear, causing the user have to buy back the ship already bought earlier.
You could either have your shop script DontDestroyOnLoad, or every time the buy button is clicked, depending on the item bought, create a new PlayerPref, every time they enter the shop, then first check your PlayerPrefs and updating the remaining unbought items accordingly.
Thank you very much for your comment, but I could you explain better how to DestroyOnLoad?
function usemodel1() {
Application.LoadLevel("Space Fever Codes#1");
}
function buy(){
if(gemcount>=500){
gemremaning = gemcount - shipcost;
gemcount=gemremaning;
buying.SetActive(false);
use.SetActive(true);
}
here is piece of the script
Essentially, how DontDestoryOnLoad works is, when a new scene is loaded, an object (or script) on the previous scene, will be transfered over to the new scene, its position, children, and everything...
The only problem you may run into, is if the script isnt self-sustrained, and by that I mea it replies on other scripts on other objects, or even other public objects, that now may not exist to function properly.
Before Application.LoadLevel, call DontDestroyOnLoad on the object that has your shop script on it.
So, it would kind of work like:
DontDestroyOnLoad(shopScriptObject.gameObject);
Application.LoadLevel("Space Fever Codes#1");
A better alternative in my opinion though, is to create a "inventory" script, that only gets populated when a player buys something, then DontDestroyOnLoad that script, and have your shop script check that script ins$$anonymous$$d, its more organized to me, but either way, works the same.
Your answer
Follow this Question
Related Questions
Creating a shopping cart in Unity scripts problems 0 Answers
Environment Arguments on single instance app 0 Answers
Is DateTime working on iOS? 0 Answers
C# suddenly no longer building on Linux 0 Answers