- Home /
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?*
Answer by salex100m · Nov 17, 2013 at 08:26 PM
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.
http://www.youtube.com/watch?v=0Tl1Cc0IRnI&feature=c4-overview-vl&list=PLCD6B6D279036462A
But to answer your question more specifically (and in pieces):
1) Click on the screen: http://docs.unity3d.com/Documentation/ScriptReference/Input.GetMouseButtonDown.html
2) Get the point on the screen the mouse is clicking: http://docs.unity3d.com/Documentation/ScriptReference/Input-mousePosition.html
3) "Create something" http://docs.unity3d.com/Documentation/Manual/InstantiatingPrefabs.html http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
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.