Unity3D笔记

1. 方向键方向基于摄像机朝向变化

float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertival = Input.GetAxis ("Vertical");
/*cam是摄像机的transfrom*/ Vector3 camForward
= Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized; Vector3 move = (moveVertival * camForward + moveHorizontal * cam.right); rb.AddForce (move * speed);

 

posted on 2016-09-23 16:58  darkness_1  阅读(135)  评论(0编辑  收藏  举报

导航