People, I’m new with this great tool and I would like to post 3 questions:
a) How can I save the game status ? I mean, let’s say I have several levels and I would like to save where I am at that point of the game.
b) How to retrieve the saved game ?
c) How to make a “flying camera” and how to switch between cameras ?
a.) The simplest way is to store all the current game data (for example, the player’s position in the level, his health, ammo, where the AI is located, ect…) in a text file. You’d probably want to at least save it as binary so users can’t edit it.
b.) The the save game file and pretty much reset everything to where it was using the info you read in.
c.) I’m not sure how to make a “flying camera”, I know Erich has done this. To switch cameras is pretty easy. You’d just set the enabled property to either true or false for each camera (e.g. camera.enabled = true;) or set the tag of the camera to “Main Camera”. I’m not sure which one is suggested to use.
Probably easier to use PlayerPrefs instead of a text file. It’s up to you how to implement it, though…depends on what sort of data you want to save exactly.
All active cameras all render to the screen. The “Main Camera” tag doesn’t do anything except allow Camera.main to function properly. Extra enabled cameras can slow down the game, so make sure only one camera is enabled at a time (unless you know what you’re doing).
The best flying camera script (IMO) I’ve come across yet is: http://forum.unity3d.com/viewtopic.php?t=6097&highlight=flying
The GameObject is the parent. At least, I haven’t been able to make it work the other way around, and the scripts can all attach to the GameObject.
I’m still working on the switching cameras thing myself.
The solution we are probably going to use to store progress is to set cookies in the browser, since we are making a web player type and we won’t consider it critical that they can’t hack their way into higher levels. Maybe we’ll use some sort of encryption, I don’t know yet.