官术网_书友最值得收藏!

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?

主站蜘蛛池模板: 灵石县| 湘阴县| 秦安县| 黔江区| 吉首市| 梁河县| 会宁县| 阿鲁科尔沁旗| 吉木萨尔县| 原平市| 天津市| 皮山县| 庆城县| 罗田县| 鄄城县| 梁平县| 浏阳市| 五峰| 崇左市| 重庆市| 宝清县| 柯坪县| 双城市| 平舆县| 建湖县| 交口县| 广丰县| 布尔津县| 栖霞市| 尼勒克县| 文安县| 光泽县| 北海市| 乌恰县| 甘肃省| 嘉禾县| 韶关市| 甘洛县| 米易县| 井研县| 响水县|