Labels

Friday, April 1, 2016

Unity入门教程之ROLL-A-BALL 学习笔记 Part I

Unity入门教程

ROLL-A-BALL 学习笔记

1     环境和PLAYER设置

1.1    环境Environnement 设置

创建新场景:File->New SceneCtrl + S
创建Gameboard/Play Field GameObject->3D Object -> Plane
重命名新建Plane名称 :点击Plane,按下Enter重命名
Reset Object:单击右上方的 Context sensitive gear menu -> Reset
Reset Object 使objectPostion调整在x=0, y=0, z=0
To see the entire game object in the Scene View: Edit -> Frame Selected (F)
显示/关闭Grid lines:在Scene ViewGizmo菜单下选择或取消选择Show Grid
Rescale object有三种方法:

1.      快捷键R,拉动三个坐标轴
2.      inspector菜单下的Transform栏里拖动Scale
3.      inspector菜单下的Transform栏里填写Scale数值
注意:Rescale plane时要注意plane没有volume所以scale planey坐标轴没有意义,通常y=1
创建objet三部曲:
1.      Rename
2.      Reset position
3.      Frame Selected
更改objet颜色三部曲:
1.      创建Materials文件夹,选中Materials文件下,ProjectCreate->Material
2.      inspector菜单下Aibedo栏更改颜色
3.      拖动Material Scene View中需要着色的object
转动the main directional light : 选中Directional LigthTransform Component中更爱Rotation x=50 y=60 z=0,以达到更好的光照效果

1.2    PLAYER设置

object增加physics属性:先选择objectComponent ->Physics ->Rigidbody ;或者是在inspector菜单下点击Add Component->Physics ->Rigidbody 
如何让player得到外界input
1.      新建Scripts放置C# scripts
2.      inspector菜单下点击Add Component->New Scripts (both create and attach script in one step), 重命名scriptPlayerController
3.      把新建的script拖入scripts文件夹中
Startis called on the first frame that the script is active,放置初始化code
Updateis called before rendering a frame,放置一般code
FixUpdateis called just before performing any physics calculations,放置physics code
LateUpdateit is guaranteed to run after all items have been processed in updatefor follow cameras, procedural animation and gathering last known states
注意:Script里的public变量可以在Inspector菜单里直接赋值,方便调试
数据结构:
·        Rigidbody,为object增加物理属性,使用AddForce(Vector3)方法使object移动
·        Vector3 三个方向的数据结构

No comments:

Post a Comment