Unity控制移动

虚拟轴控制移动

void _Move()

{

if(Input.GetKey(KeyCode.A)||Input.GetKey(KeyCode.D)||Input.GetKey(KeyCode.S)||Input.GetKey(KeyCode.W))

{

Vector3 Keyv3=new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));

transform.position+=Keyv3*10*Time.deltaTime;

transform.forward=Keyv3;

}

}

猜你喜欢

转载自blog.csdn.net/weixin_42304838/article/details/81182429