Unity3d 人物的跳跃
果然谷歌就是无敌, 不过都是定位到unity的community里的void Update(){// Jumpif (Input.GetButtonDown("Jump")){if (grounded == true){float h = Inpu...
·
果然谷歌就是无敌, 不过都是定位到unity的community里的
void Update(){
// Jump
if (Input.GetButtonDown("Jump"))
{
if (grounded == true)
{
float h = Input.GetAxis("Horizontal"); // A D
float v = Input.GetAxis("Vertical"); // W S
//Debug.Log(h + " " + v);
if (Input.GetKey("w"))
{
playerRigidbody.velocity = transform.forward * (v * speed);
}
if (Input.GetKey("s"))
{
playerRigidbody.velocity = transform.forward * (v * speed);
}
if (Input.GetKey("a"))
{
playerRigidbody.velocity = transform.right * (h * speed);
}
if (Input.GetKey("d"))
{
playerRigidbody.velocity = transform.right * (h * speed);
}
playerRigidbody.AddForce(new Vector3(0f, jumpForce, 0f));
grounded = false;
}
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)