• Unity3D项目


    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"))

  • 相关阅读:
    vm扩容
    手算二维离散傅里叶变换
    取消vim模式匹配的高亮
    DS DI ES SI等等
    int and Integer
    为什么超类能引用子类的对象
    voltile解析
    java集合
    疑问:无限定通配符
    layui table 导出
  • 原文地址:https://www.cnblogs.com/woloveprogram/p/4669912.html
Copyright © 2020-2023  润新知