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 /
This question was closed Nov 02, 2014 at 11:04 PM by vexe for the following reason:

Too subjective and argumentative

avatar image
0
Question by PuneetK · Jan 26, 2014 at 09:40 AM · 2d2d-platformerloadingresources

2D Infinite Runner questions

Alright, guys I'm looking into making a 2D infinite sidescrolling runner game in the new 2D framework.

Here are a few questions I want to materialize concretely into solid answers before I start working on it.

  1. Is it better off to move the background/floor backwards, or move the player forward? I'm going for a jetpack joyride style infinite runner where the player's X position will be fixed on the screen.

  2. I want to have the game load all the resources ONCE in the starting. I have pro version so I can use LoadLevel Async, but how would I be able to load ALL resources in the start, without having any load time before actually loading the level?

  3. Let's say I somehow load everything at the start of the game, is it still possible to cycle through a list of gameobjects. For example, for random generation of the floor, I would require a list or array of gameobjects. Generally I would do this by dragging and dropping the required assets into the inspector field. But if I load everything at the start, I am assuming I would have to use a different approach. Could someone please explain how this would work out?

  4. Far saving user data, such as upgrades bought, levels completed, etc. is there a better way (or rather, SAFER way) than PlayerPrefs? I was watching a video tutorial by someone at Unity and he said playerprefs aren't very reliable as they are stored in a text file on the hard disk. He didn't specify the alternative though, so if you know how to store data more securely using playerprefs, please let me know.

Comment
Add comment · Show 1
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 robertbu · Jan 26, 2014 at 10:02 AM 3
Share

Unity Answers is designed for answering single, specific questions. In addition UA does not handle discussions and matters of opinion very well. I suggest you close the question here and open this question on the Unity Forums. Or alternately some of your issues could be asked as individual questions.

BTW: I'd move the terrain and leave the camera and character near the origin. Depending on your speed and distances, moving the character can result in smoothness issues as distances get larger and therefore floating point imprecision becomes greater.

3 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Invertex · Jan 26, 2014 at 09:51 AM

1) No, just move the character forward. You'll link your camera's X,Y position with the Player, so it will always be centered on the screen.

edit: robertbu brought up a good point, so it's worth considering just moving the level if you truly plan on this being "infinite"

2) http://docs.unity3d.com/Documentation/ScriptReference/Resources.LoadAll.html

3) Use LoadAll to load a directory and type of resource into an array:

http://answers.unity3d.com/questions/287593/using-resourcesloadall-with-arrays.html

4) Yes, use SerializeXML. It offers a lot more freedom.

http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer

Comment
Add comment · Show 7 · 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 PuneetK · Jan 26, 2014 at 10:05 AM 0
Share

Just a question about Resources.LoadAll, I'd be using that line of code in my loading screen script, and be saving it in an array (following the example in the scripting reference). But how do I reference this array in a different level/scene? I dont want to do LoadAll again

avatar image Invertex · Jan 26, 2014 at 10:08 AM 0
Share

You can set the object the script is on to DontDestroyOnLoad, so it will persist throughout level loads.

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

avatar image PuneetK · Jan 26, 2014 at 10:30 AM 0
Share

So here's how the workflow would be?

  1. Load everything at the start. In say a script called Resourse Script.

  2. $$anonymous$$ake the script's gameobject as dontdestroyonloaf

  3. In my actual gamemanager script, I would make a reference to ResourceScript by using GetComponent.

  4. Store those variables locally in Gamemanager?

Just let me know if this is correct, or theres something more efficient/easier

avatar image Invertex · Jan 26, 2014 at 10:36 AM 0
Share

Sure, although you could skip the referencing and just use the resource script as your Game$$anonymous$$anager script, after all, you want your Game$$anonymous$$anager to persist through the level loads as well, or else you'd need to do a save and load of your player stats on every level change, ins$$anonymous$$d of just at save points (unless autosave is a feature you intend on using, but even still, you'll be incurring that LoadX$$anonymous$$L overhead.)

avatar image PuneetK · Jan 26, 2014 at 10:42 AM 0
Share

Could you expand a bit more on how that'd work?

Show more comments
avatar image
0

Answer by iKatsuX3 · Feb 24, 2014 at 08:35 AM

I have a simple answer to your question, maybe it sums it up.

Let the background move while your character justs loops his/her running motion. So, Loop the background while the character "pretends" to be running and randomly generate coins,lasers,and enemies.

Loading is really "needed" for a game to work. If you expect the game to start directly without loading then... I don't know... Impossible? Most games load all the resources at the beginning. Examples of these are games from valve and the bioshock series. They all have loading screens that will just load the "required" resources.

I think that's all I have. :p

iKatsuX3

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 Internetzoo · Sep 11, 2015 at 02:09 PM 0
Share

I did that and Im having a bit of trouble, my object(i.e. coins/lasers) is just stuck in the middle of the screen, im pretty sure im missing something or will i have to move the quad forward automatically

avatar image
0

Answer by marudhu · Sep 15, 2014 at 05:53 AM

Hey If you are looking for 2D Endless Running with Jumping, I had found a reference game: "Mojo Run" from the Unity asset store.

Hope it helps you.. Thanks..

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

22 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

Related Questions

Why does my character pass through walls when he respawns and I lose control of him? 2 Answers

How to sync animation if animation should be use with specially object 0 Answers

Tutorial Program will not Run (First time in Unity) 1 Answer

Problem with akward wave "Rendering",Tilemap/Grid akward wave effect 0 Answers

Farseer Physics and Character Control 0 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