- Home /
Too subjective and argumentative
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.
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.
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?
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?
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.
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.
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
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
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
So here's how the workflow would be?
Load everything at the start. In say a script called Resourse Script.
$$anonymous$$ake the script's gameobject as dontdestroyonloaf
In my actual gamemanager script, I would make a reference to ResourceScript by using GetComponent.
Store those variables locally in Gamemanager?
Just let me know if this is correct, or theres something more efficient/easier
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.)
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
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
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..
Follow this Question
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