public float speed = 6f;
Vector3 movement;


void FixedUpdate () {

float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Move(h,v);
}

void Move(float h,float v)
{
movement.Set(h, 0f, v);
movement = movement.normalized * speed * Time.deltaTime;
GetComponent<Rigidbody>().MovePosition(movement+transform.position);//当前位置+移动的位置
// transform.position = movement + transform.position;//与上一行一样的方法


}

posted on 2016-04-27 11:49  独蠢无双  阅读(7768)  评论(0编辑  收藏  举报