- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 280字
- 2021-07-02 19:59:32
Teaching behavior to GameObjects
You have Unity because you want to make a game or something interactive, such as an AR or VR experience. You've filled your game with dumb GameObjects. What you have to do now is be their teacher. You have to teach them everything that they need to know to live in this world of make–believe. This is the part where you have to write down instructions so that your GameObjects can be smarter.
Here's a quote from the Unity Manual:
"The behavior of GameObjects is controlled by the Components that are attached to them... Unity allows you to create your own Components using scripts."
Notice the word behavior. It reminds me of a parent teaching a child proper behavior. This is exactly what we are going to do when we write scripts for our GameObjects: we'll teach them the behaviors we want them to have. The best part is that Unity has provided a long list of all the behaviors that we can give to our GameObjects. This list of behaviors is documented in the Scripting Reference.
This means that we can pick and choose anything that we want a GameObject to do from this list of behaviors. Unity has done all the hard work of programming all of these behaviors for you. All we need to do is use some code to tie into these behaviors. Did you catch that? Unity has already created the behaviors; all that we have to do is supply a bit of C# code to apply these behaviors to our GameObjects. Now, how difficult can it really be since Unity has already done most of the programming?
- JavaScript高效圖形編程
- 造個小程序:與微信一起干件正經事兒
- 簡單高效LATEX
- Visual FoxPro 程序設計
- JavaScript前端開發與實例教程(微課視頻版)
- STM32F0實戰:基于HAL庫開發
- The Complete Coding Interview Guide in Java
- 一本書講透Java線程:原理與實踐
- Python Interviews
- Django實戰:Python Web典型模塊與項目開發
- Web前端開發最佳實踐
- 例說FPGA:可直接用于工程項目的第一手經驗
- HTML5 and CSS3:Building Responsive Websites
- JavaScript重難點實例精講
- 3ds Max瘋狂設計學院