- Home /
Saving some aspects of game (save strategy)
Hello!
So i am making this counter-strike managet (look up CS manager) clone jut for fun and i have come to the point where i would like to save a strategy i have set up to be used later. How would i go about it? I did not know what to look for in the forums or unity answers. Please give me a direction to start heading. I have read about serialisation a little bit but what i have understood so far it is not exactly the right thing for my problem.
For anybody who doesnt know what CSM is or is too lazy to look it up i basicly set up astrategy for my soldiers to follow and hit play. And i want to create these strategies and save them and then use them against other peoples strategies.
I hope you guys can help with this.
Thanks in advance!
Basicly the player can define where each of his soldiers hae to move in a match. This is a strategy. I want the player to be able to create said strategy and save it to be used in several matches.
PS: Check out www.CS-manager.com
I'm assu$$anonymous$$g from the link you've provided, you're talking about the tactics screen that i can see on the front page. So the idea is, give your NPC soldiers a set of orders and they'll do what you've told them. Is that correct? Which part of this are you having difficulty with? The saving and loading of created strategies?
Exactly. Also i dont know if this comes into play in some way or not, but the strategies of 2 players must be loaded and then executed simultaneously. By that i mean that the tactics are loaded onto the map and then played against each other. I have build the logic behind the strategy making (waypoints and so on) but i dont know how to save them to be used later.
Answer by Kiwasi · Jun 10, 2014 at 12:09 AM
For those of you too lazy to look up the documentation on saving follow this link. You do actually have to click the play button yourself.
This was a little bit helpful, but i still dont get it. How do i save the existance of an object and its position? For example if i have a set of waypoints for a soldier to follow. How do i set these waypoints, their positions and rotations and the relations to each other (their order)?
You do exactly as he did in the video. Create a custom serilizable class with all the saved data. Serialise the class. Write the class to a file.
Note that Vector3 and Quaterion are not inherently serilizable classes. You will need to break these down into their component floats and then reconstruct them.
Another option is to use this prebuilt solution