zoukankan      html  css  js  c++  java
  • 摄像机跟着鼠标左右移动而移动,上下移动而前进后退

    private float cameraMoveSpeed = 1.5f;
    void Update()
    {
    moveThisCamera();
    }
    void moveThisCamera()
    {
    if (Input.mousePosition.x <= 10)
    {
    float xNew = this.transform.position.x;
    xNew -= cameraMoveSpeed * Time.deltaTime;
    this.transform.position = new Vector3(xNew, this.transform.position.y, this.transform.position.z);
    }
    if (Input.mousePosition.x >= (Screen.width - 10))
    {
    float xNew = this.transform.position.x;
    xNew += cameraMoveSpeed * Time.deltaTime;
    this.transform.position = new Vector3(xNew, this.transform.position.y, this.transform.position.z);
    }

    if (Input.mousePosition.y <= 10)
    {
    float zNew = this.transform.position.z;
    zNew -= cameraMoveSpeed * Time.deltaTime;
    this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, zNew);
    }
    if (Input.mousePosition.y >= (Screen.height - 10))
    {
    float zNew = this.transform.position.z;
    zNew += cameraMoveSpeed * Time.deltaTime;
    this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, zNew);
    }
    }

  • 相关阅读:
    人生无常 淡然处之
    对PHP开发的认知
    专家路线
    很少接触的文学
    懒加载
    Markdown入门 学习
    (转载)iOS开发历程书籍推荐
    ObjectiveC1基础代码——类和对象
    day11基础代码——函数指针
    day6
  • 原文地址:https://www.cnblogs.com/Study088/p/7298627.html
Copyright © 2011-2022 走看看