- Home /
Simple Unity Coding...
Good day...
I am an intermediate programmer and having a problem on how to use Unity scripts... I would like to ask for your help just a simple one on how to programmaticaly:
Create a 3D or call a 3D object during runtime.
Control camera during runtime (3rd person).
That is all for now. I am planning to design a game and i hope that you can help me through it. I will just need a simple code and i will do the rest. I will post the final code here so that everyone can make reference on it on the future...
Thank you so much...
Answer by CHPedersen · Sep 02, 2013 at 06:51 AM
It's unclear what you mean by "Create a 3D or call a 3D object during runtime". Do you mean instantiate an object so it appears in the scene, and calling a method in a script attached to a gameobject?
As for camera control, please see the standard Character Controllers that comes with Unity, available through Assets->Import Package->Character Controller. It will import a rich package of available character controllers which includes camera movement. Study those examples.
i mean GameObject... Is it possible to start it blank then you call all of the necessary GameObjects(Terrain, Character, etc..) when you run the game?
Yes, certainly. You could have your entire game created solely from custom code and run off of a single GameObject with a single script serving as an access point, if you wanted to. But you have to have at least one GameObject.
Answer by Imawizrd · Sep 02, 2013 at 06:57 AM
Create a 3D or call a 3D object during runtime.
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.html
This is your "3D object" in Unity we call it a GameObject.
Read through this to learn how to create a GameObject during runtime: http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
This one finds a GameObject at run time:
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.Find.html
Control camera during runtime (3rd person).
Using the Camera's Transform component http://docs.unity3d.com/Documentation/ScriptReference/Transform.html
You could adjust the position and rotation of the camera at runtime.
If you would like to learn more head to this link: http://unity3d.com/learn/tutorials/modules
Do you have any example that starts on blank but when the game run the script will load Game Objects?
Your question is unclear. I'm going to assume you want to create a game object at run time. Therefore please read the information on this page. http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
Additionally, I suggest taking the time and and completing the tutorials on this page: http://unity3d.com/learn/tutorials/modules
Or finding a tutorial to follow on YouTube which will take you through the basics of Unity.
http://www.youtube.com/watch?v=Q$$anonymous$$Wht$$anonymous$$jUr10
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Can't find MonoDevelop. Unity 4.5.2 1 Answer
Can I call a js script method inside a C# dll project? 1 Answer
How to find a script from another Scene? 2 Answers
need enemeyAI with near follow 2 Answers