Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 toddisarockstar · Oct 09, 2015 at 08:45 PM · turn based

turn based game over long time period

i have an idea for a simple turn based game. i would like to allow for players to stop and continue the game over days/weeks. i would prefer an android game. game progress and player ips could be simply saved in something as simple as a text document or string somewhere. my game could access and reload / connect when players open the game.

i am looking for advice on the simplest way where/how to store the data/string required?

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

1 Reply

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

Answer by Statement · Oct 09, 2015 at 08:53 PM

Expect that IP addresses change between runs.

  • System.IO.File to get file access.

  • Application.persistentDataPath to get file storage.

Simple text file methods to use are File.WriteAllText, File.ReadAllText.

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 toddisarockstar · Oct 09, 2015 at 09:07 PM 0
Share

i have used some of these commands youre mentioning in my last project. i know they dont work for webplayers. are you sure they work for android? if so that makes for a very easy answer for me!!!

also are you saying on reconnect that ip addresses change? So then would it make sence i should connect to the gamename and exchange if same player names are connected?

avatar image Statement toddisarockstar · Oct 10, 2015 at 11:17 AM 0
Share

For webplayer, you could possibly get away with saving stuff in PlayerPrefs with GetString and SetString. If you want to save arbitrary binary data, base64 encode it first. There is a limit on how large the string can be, but IIRC it can be roughly 250 kB until things get nasty. I did some tests on this in 2009 so things may have changed since :-)

I'm saying expect that they will change between runs if you have pauses of days/weeks. It all depends on the network configuration (static/dynamic ip etc). Yes, it would make sense to use a unique identifier ins$$anonymous$$d of an IP which may change/get swapped etc.

avatar image Bunny83 Statement · Oct 10, 2015 at 11:28 AM 0
Share

As i understand @toddisarockstar's comment he only want to build for Android and was worried if file io will work there. So the straight answer is: Yes, you can create, read and write files on Android as long as you have permissions for the folder you want to write to / read from.

@toddisarockstar:

$$anonymous$$eep in $$anonymous$$d that Android is a Linux based OS. So file and folder names are case sensitive and use "/" ins$$anonymous$$d of "\".

To build valid files names you might want to use System.IO.Path.Combine.

avatar image toddisarockstar · Oct 10, 2015 at 07:43 PM 0
Share

very good info from Statement and bunny83 both. thanks guys! ideally i soppose it would be good to create a server and store there but thats a little ahead of me so i will be saving the server method for another day. I will be coding with the methods you guys describe!

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

31 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Click to Change Public GameObject Variable 1 Answer

How to store player input in turn-based game? 0 Answers

TBG,If,While 1 Answer

Help with turn based Movement in a grid 2 Answers

Controlling the curvature of a Bézier curve 2 Answers


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