- Home /
City Managment in open world game.
Ok so this may seem complicated but I will do my best to paint a picture of what I am trying to create.
I am creating a game that has 3rd person aspect to it where you have a hero that is customizable with stats, armor etc. You can go around the land (sandbox style) fighting random mobs and also capturing cities and villages. When you do the people within the city are persuaded to join you. With that you are able to customize the cities you capture. I want to know how to implement a city management system so to speak ( I have the 3rd person part down pat so no need for help there) so when the character reaches the city it will give me the option (GUI BUTTON) to customize the city, if I hit "yes" it will bring up a screen of the city and allow me to use GUI or something of somekind to create buildings, troops, defences etc.
If anyone can assist me, I am not necessarily looking for free code, I honestly want to know if this is possible and how to go about doing it. A few lines of example code would help me if you wish to provide. I am faily new to scripting but have spent the past 4 months self learning so I am not a complete noob.
for visual sake I am looking for something similar to the game "banished" in the sense of creating cities/villages but not as far as the micromanaging of resources it uses.
Thank you in advance. Please ask any questions if you need clarification.
I'd ask you to post your existing code for your "city" script but I get the feeling you have yet to write a single line of this game, unless you count copying the 3rd-person controller script from the docs, which you probably are. From your description, this is way too big an idea for a first game and you will never finish it. Start with something no more complicated than Breakout or Frogger and you have a chance.
One other bit of advice- OnGUI sucks so very much. Avoid it if you can. You will have a better time if you make your buttons ordinary game objects with colliders and put them on their own Layer seen by an orthographic camera.
Answer by MakeCodeNow · Mar 02, 2014 at 07:18 PM
This is a huge question and not really one that anyone can answer in a succinct way. What you want to do is absolutely doable in Unity, but it is a lot of work. Way more than just a few lines of code. The best advice I can give is that you need to break this big challenge down into much smaller problems, pick a starting point, figure out how to implement that first piece, and then move on to the next. As you go, you'll probably run into specific issues, and you can search or post here for help as you run into them. As it is, you're question is too close to "please explain to me how to make a complex game" for folks here to be able to help much.
Good luck!
I understand this is a huge question and I wanted to know if it was in fact possible within Unity so Thank you $$anonymous$$akeCodeNow for answering that.
I have in fact coded the rest of the game including 3rd person aspect and creation of the rest of my game with spawn points, mob creation etc. I am just not familiar with the creation of objects through an in game screen of some kind which was what I wanted clarification on. I was just looking for someone who possibly had some experience with it and could point me in the right direction. If I know how to create even a single item I could do the rest myself and learn from there. How would you go about doing it? You say GUI isn't the way to do it, so what would you recommend?
Any assistance would be great! Thank you.
You said "creation of objects" but from your original question, it just sounds like you want to set variables. I don't know if your cities are a simple icon on an overhead map, or a 3d space you can walk through, which would make a big difference in how difficult it would be to "customize" them.
Either way, for buttons you do a raycast to Camera.main.ScreenToWorldPoint(Input.mousePosition)
(you can find plenty of raycast example code) and then check "Hit.collider.tag" to deter$$anonymous$$e what was clicked. If the tag is right, then you can call a function or set a variable on the script attached to the clicked object.
I don't think this question should be open much longer.
Just want to add that I am currently working on a project that has a lot of classes, and different versions of classes.
I found it a lot easier to manage when using gameObjects and add components to them. $$anonymous$$akes it a lot easier to visualize the data, for me.
Thank you, I will look into raycasting to see if it will suffice for what I am trying to do.
Your answer
Follow this Question
Related Questions
Creating a mesh over a terrain 0 Answers
How to make gui image button revolve 2 Answers
Look like a Website Menue! 1 Answer
GUI.Button simple dropdown menu problem 0 Answers
detect collider with button movement 1 Answer