woloveprogram

Input.mousePosition //鼠标点击的位置

0 左键  1右键  2滚轮

Input.GetMouseButton(0) //当鼠标左键处于按下状态的时候返回True

Input.GetMouseButtonUp(0)//当鼠标左键抬起的时候返回true

Input.GetMouseButtonDown(0)//当鼠标左键按下的时候返回true

Input.GetAxis("Mouse X")  //在水平移动距离

Input.GetAxis("Mouse Y")  //在垂直移动距离

跟着鼠标 旋转

float x1=Input.mousePosition.x-xZero;

float y1=Input.mousePosition.y-yZero;

float angle=90f;

if(y1!=0)

{

  angle=Mathf.Atan(x1/y1);

  angle=180*angle/Mathf.PI;

}

if(y1<0)

{

     angle+=180;

}

transform.localRotation=Quaterniton.AngleAxis(angle,Vector3.up);

Alpha0  表示数字0;

通过按键 控制英雄向左右走

if(Input.GetKey(KeyCode.W))

{

  if(Input.GetKey(KeyCode.LeftShift))

  {

      animation.Play("Run");

      speed=3f;
  }
 else

  {

    animation.Play("Walk");

    speed=1f;

  }

  transform.Translate(Vector3.forward*speed*Time.deltaTime);

}

else

{

  animation.Play("Idle");

}

transform.Translate(Vector3.forward*Input.GetAxis("Horizontal"))

 

分类:

技术点:

相关文章:

  • 2021-12-27
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-10-16
  • 2021-10-16
  • 2021-10-16
猜你喜欢
  • 2021-07-09
  • 2021-10-16
  • 2021-10-15
  • 2021-04-17
  • 2021-10-16
  • 2021-10-16
  • 2021-12-18
相关资源
相似解决方案