标签:
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, transform.position.y, v);
movement = movement.normalized * speed * Time.deltaTime;
GetComponent<Rigidbody>().MovePosition(movement+transform.position);//当前位置+移动的位置
// transform.position = movement + transform.position;//与上一行一样的方法
}
标签:
原文地址:http://www.cnblogs.com/wangweixznu/p/5438322.html