Create object inside a game

hello to all
you have never played Age of Empires?
I wanted to create something that you can build objects from inside the game. (example, on aoe you can create stables, castles, houses)
how do I do that if clikko on a box then place the mouse makes me the object I want to create?

sorry if I was unclear

how i can do that if i click on a box then place the object on a mouse position?*

1 Answer

1

Your question is very broad and is like asking “how do i make a game”. There are a ton of tutorials out there that will help you get started. I like quill18creates’s series, but I’ve watched hours of other tutorials as well. I suggest you start there.

But to answer your question more specifically (and in pieces):

  1. Click on the screen:
    Unity - Scripting API: Input.GetMouseButtonDown

  2. Get the point on the screen the mouse is clicking:
    Unity - Scripting API: Input.mousePosition

  3. “Create something”
    Unity - Manual: Instantiating Prefabs at run time
    Unity - Scripting API: Object.Instantiate

  4. “Create a house or something”
    well you need a model of a house to start with… so

4a) http://forum.unity3d.com/threads/54064-How-to-Make-a-3D-Model
4b) Import that model into unity
4c) Make a prefab Gameobject of that model (google search “unity3d prefab”)

So putting it all together, once you have the prefab’d “house”, you can click on the mouse and instantiate the house

Like I said, you should just watch and copy those video tutorials until you can replicate their projects. You’ll learn all these steps there.