1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. public class L12 : MonoBehaviour
    5. {
    6. public float moveSpeed = 10f;
    7. void Start()
    8. {
    9. }
    10. // Update is called once per frame
    11. void Update()
    12. {
    13. //自定义移动
    14. transform.Translate(new Vector3(1, 0, 0));
    15. //可以不输入数值,控制移动
    16. transform.Translate(Vector3.up * moveSpeed * Time.deltaTime);
    17. //可以不输入数值,控制旋转
    18. transform.Rotate(Vector3.up * moveSpeed * Time.deltaTime);
    19. //以上Vector3.* 的快捷键操作应用于局部轴,而不是世界轴。
    20. //如果想用碰撞体移动某个对象,则不应该使用Translate 和 Rotate 函数,而应该考虑使用 Physics 函数
    21. }
    22. }