- Home /
How to save the player?
hey guys ive searched all day long and i got nothing... my problem is: i design a character creation system. look at ---> https://www.youtube.com/watch?v=h7UR2Jk_OvA
and i dont know how the hell make something like a prefab of the creation... i was reading, and reading, but the most closest thing that i found was in C#, and i barelly known C# :(
this is my code(useless at the moment):
var CharToPrefab: GameObject;
var CharToName: GameObject;
var CharName: String;
var IsDoneP: GameObject;
var Proceed: boolean = false;
var IsSpirit: boolean = false;
function Update(){
Proceed = IsDoneP.GetComponent(DeactiveBlockScreen).PrefabIsDone;
CreatePrefab();
CharName = CharToName.GetComponent(TextName).namefield;
}
function CreatePrefab(){
if(Proceed==true&&IsSpirit==true){
PrefabUtility.CreatePrefab("Assets/PlayerPrefab/SPIRIT/"+CharName+".prefab");
}
}
So if you watched the video, when you click on the green "Y" button: the window closes and the PROCEED bool become TRUE and so the "prefab creation process" begins... but here is where im stuck..
can anyone help me with this? how to save the player in a prefab, or an asset, with its own materials and stuff(something like: copy the materials and the models, and the hierachy of the object, and make a copy of that so when i want to create another character if i modify these materials, like colors and stuff, the old character will keep their own info) i dont know if i make it clear.. maybe my english is not so good.. ahaha, apoligize for that...
PD: if u are wondering "what the hell is that IsSpirit thing is?" A: that is because i will do another GUI for a "biological creature" creation, so in this case IsSpirit, you got it? :D
Is making the object as not a new prefab acceptable? It'd be much easier to make a generalized spirit prefab that you shape via data.
and how can i do it? im starting to lose my $$anonymous$$d on this ahahaha
I think he means that you have a general model, and enable different materials on it depending on what you need. Or perhaps change the mesh in the mesh component depending on what you need. And you just save an integer number in player prefs, and have a script read that number on start, and do what is needed on the model, like change the material to the one you want.
Answer by screenname_taken · Mar 26, 2014 at 04:19 PM
I'm not sure you can make a prefab from the player. That may just be an editor thing only. But, you could take the gameobject created from the various options, pass it through the serializer and save it as a file or as a string in player prefs. http://heureka.dk/?p=740