赞
踩
void Move()
{
Vector3 dir = Vector3.zero;
if (cc.isGrounded)//判断角色是否在地面isGrounded
{
//通过键盘控制玩家的移动
float h = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
float v = Input.GetAxis("Vertical") * Time.deltaTime * speed;
//transform.forward 是物体的z轴,但是Vector3.forward是世界坐标的z轴
//dir = new Vector3(h, 0, v);
dir = transform.right * h + transform.forward * v;
if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
{
PlayAnimation(GameRes.PlayerState.Draw);
脚步声
if (!audios.isPlaying)
{
audios.PlayOneShot(cilp);
}
}
//按空格跳跃
if (Input.GetKeyDown(KeyCode.Space))
{
transform.position += Vector3.up * 2;
AudioSource.PlayClipAtPoint(jumpClip, transform.position);
}
}
cc.SimpleMove(dir);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。