3.3.1 Rotate&Translate
用于旋转的Rotate方法和用于移动的Translate方法都有4个参数的重载形式。第四个参数为Space枚举类型,如果设置为“Space.Self”变换被应用于自身轴;如果设置成“Space.World”变换被用于相对于世界坐标系统。如果不设置,默认为“Space.Self”。
C#代码片段:
this.transform.Rotate(5,0,0,Space.World);
this.transform.Translate(5,0,0,Space.Self);
3.3.2记录时间
如果想每秒增加或者减少一个值,需要乘以Time.deltaTime,同时需要明确用戏中是需要每秒为1个单位还是每帧为1个单位。在FixedUpdate方法中,则需要乘以Time.fixedDeltaTime。
3.3.3 访问游戏对象组件 GetComponent
注意Transform和transform首字母的大小写区别,前者是类或脚本(大写),后者是变量(小写);
附加到游戏对象上的组件可以通过GetComponent方法获得。
例:
transform.Translate(1,0,0); //沿X轴移动一个单位
GetComponent<Transfor