首页 > 移动平台 > 详细

Unity Camera 自旋及沿自身坐标系方向移动(一)

时间:2018-07-10 15:22:48      阅读:507      评论:0      收藏:0      [点我收藏+]
void Update () {
  float h = Input.GetAxis("Horizontal");
  float v = Input.GetAxis("Vertical");

  if (Input.GetKey(KeyCode.J))
  {
    transform.Rotate(-Vector3.up * Time.deltaTime * 50f, Space.World);
  }

  if (h != 0 || v != 0)
  {
    Vector3 targetOffset = new Vector3(h, 0, v);
    float y = transform.rotation.eulerAngles.y;
    Vector3 targetDirection = Quaternion.Euler(0, y, 0) * targetOffset;
    transform.Translate(targetDirection * Time.deltaTime * 50, Space.World);
  }
}

  

Unity Camera 自旋及沿自身坐标系方向移动(一)

原文:https://www.cnblogs.com/fagex/p/9289092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!