Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sketchers1 · Aug 09, 2012 at 08:58 PM · playerfpsstorecoins

In-Game Store Using Collected Coins

Hey everybody! So I have an FPS shooter prefab with 3 weapons. On each level the shooter collects coins that add to his score (in the ScoreSystem script). What I wanted to do was for the coin value (ScoreSystem) to save and then when I go to the "Shop", which is a separate level, I would have the ability to buy weapons that get permanently added to the player prefab while the application is open. What scripts would I need where and what should I change to what I already have? The following link contains my scripts and the setup of the player prefab, let me know if you need more information: http://unityimageprobs.wordpress.com/2012/08/09/fps-ingame-store/

So here's what I don't know:

-access the score in the store -how to make a store where I can spend points/coins to buy new weapons to add to my prefab player

-how to actually set up the store

-how to get the weapons to be added and stay

-How to get the bought weapons to go to the object of the playerr

Thanks!!

EDIT!!!! THIS IS WHAT I HAVE SO FAR BASED ON SMALL CLIPPITS OF ANSWERS! THANKS! You have to read it to understand though: http://unityimageprobs.wordpress.com/2012/08/11/my-current-unworking-setup-for-the-store/

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ScroodgeM · Aug 11, 2012 at 12:00 AM

hmm. you should detach an object that you want to save between scenes from object that you want to change. detach it and use another way to set references or detach and attach again on scene loading to new player.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sketchers1 · Aug 11, 2012 at 08:32 PM 0
Share

Wait, Now on most levels the Score Stays, but when I use a GUI button to go to another level, the score resets! Im so confused! This is the Setup of the Store based on all of your answers so far... You have to read it to understand though: http://unityimageprobs.wordpress.com/2012/08/11/my-current-unworking-setup-for-the-store/

avatar image ScroodgeM · Aug 13, 2012 at 09:39 PM 0
Share

check that you have only one score script. check that you don't set scores externally like on initialization. if no success, make a getter/setter for score values and insert Debug.Log() to setter. note when and who changes scores value.

avatar image
1

Answer by IndieScapeGames · Aug 09, 2012 at 09:37 PM

 using UnityEngine;
 using System.Collections;
 
 public class example : MonoBehaviour {
     int coins;
     void Awake() {
         DontDestroyOnLoad(coins);
     }
 }

Use the DontDestroyOnLoad() method.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sketchers1 · Aug 09, 2012 at 09:39 PM 0
Share

What would that be attached to? Would it work with my ScoreSystem because its Javascript...

avatar image ScroodgeM · Aug 09, 2012 at 10:16 PM 0
Share

this is an example, it needn't be attached, use

http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

in script needs to stay alive. this would work with JS too.

avatar image ramonfr · Aug 11, 2012 at 08:52 PM 0
Share

You could keep a GameObject with a script containing "DontDestroyOnLoad(this)". This object will keep the player's data and will be present in all the scenes. If you want to get or add some data, you can simply ask to the script.

The prefab will then be loaded in the gameplay scene based on what this script says.

You didn't say if you are going to use a database. If the the game is offline it's a different approach for the store system.

Are you going to use a database?

avatar image sketchers1 · Aug 11, 2012 at 09:13 PM 0
Share

Um, no I am not going to use a database. $$anonymous$$y game is offline. (Using Free Unity)

avatar image
0

Answer by nixtwiz · Aug 11, 2012 at 09:16 PM

Why not use an I/O save system of some sort? Just have it save the amount of coins you collect at the end of each level to a file. Then the store accesses this file, reads the amount of coins you have and takes away how much you spend and then saves it again. Then it opens another file of what you have purchased, which is opened at the start of each level to see what weapons are available to you. The only problem with this is you would probably want to create a different language for it in a sense so players can't open the file and edit it. By this I mean making all numbers letters, making the numbers inverted, things like that that players may not be able to figure out. just something like "if this digit equals this, the digit in the in the int read and used in the code is equal to something else" <-my awesome psuedo code

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sketchers1 · Aug 11, 2012 at 09:56 PM 0
Share

Uh... That seems a little complicated, also seeing as I have already begun a current store. Thanks for the advice though! This is the Setup of the Store based on all of the answers so far... You have to read it to understand though: http://unityimageprobs.wordpress.com/2012/08/11/my-current-unworking-setup-for-the-store/

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

FPS Character with model 6 Answers

Respawn Player / enable new camera 0 Answers

FPS Arm Model 1 Answer

How do you change gravity with a press of a button? Unity 2D 2 Answers

Question about FPS Player Script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges