zoukankan      html  css  js  c++  java
  • Unity3D 物体按键WASD转头并移动

             // 按W键,向上移动
            if (Input.GetKey(KeyCode.W))
            {
                Vector3 e_rot = transform.eulerAngles;
                e_rot.x = -90;
                e_rot.y = 0;
                e_rot.z = 0;
                transform.eulerAngles = e_rot;
                transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self);
            }
            // 按S键,向下移动
            else if (Input.GetKey(KeyCode.S))
            {
                Vector3 eulerAngles = transform.eulerAngles;
                eulerAngles.x = 90;
                eulerAngles.y = 0;
                eulerAngles.z = 180;
                transform.eulerAngles = eulerAngles;
                transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self);
            }
            // 按A键,向左移动
            else if (Input.GetKey(KeyCode.A))
            {
                Vector3 eulerAngles = transform.eulerAngles;
                eulerAngles.x = 0;
                eulerAngles.y = -90;
                eulerAngles.z = 90;
                transform.eulerAngles = eulerAngles;
                transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self);
            }
            // 按D键,向右移动
            else if (Input.GetKey(KeyCode.D))
            {
                Vector3 eulerAngles = transform.eulerAngles;
                eulerAngles.x = 0;
                eulerAngles.y = 90;
                eulerAngles.z = -90;
                transform.eulerAngles = eulerAngles;
                transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self);
            }
    

      

  • 相关阅读:
    数据库连接池技术
    选择存储引擎的基本原则
    建索引原则
    数据库应用优化
    PDO
    关于cookie和session
    php常见漏洞及分析
    随便写
    spring 注入
    idea导入eclipse项目
  • 原文地址:https://www.cnblogs.com/yuwuji/p/7979468.html
Copyright © 2011-2022 走看看