unity CharacterController move/simplemove参考自己轴的方向的运动(以自己局部坐标系)

来源:互联网 发布:hdr as200v 软件 编辑:程序博客网 时间:2024/05/22 04:58

Vector3  move_direction;

CharacterController   controller;


move_direction=new Vector3(V,0,H);//从键盘输入的方向值

 Vector3 current_direction=transform.TransformPoint(move_direction) - transform.position;//用以自己为参考的目标点的世界坐标减去自己的世界坐标

controller.move(current_direction*Time.deltaTime);//move移动方向是以世界坐标为参考方向的

//如果只是单纯的向对象前方移动,还可以用:

controller.move(transform.forward*walk_speed*Time.deltaTime);//transform.forward指对象的z轴

0 0
原创粉丝点击