zoukankan      html  css  js  c++  java
  • 摄像机跟随手指旋转

    using UnityEngine;
    
    public class CameraRotateFollowFinger : MonoBehaviour {
    
        bool isRotating = false;
    
        public GameObject player;
    
        /// <summary>
        /// 旋转速度
        /// </summary>
        public float speed = 100;
    
        void Update () {
    
            RotateView();
        }
    
        void RotateView()
        {
            if (Input.GetMouseButtonDown(0))
            {
                isRotating = true;
    
                //unity Input内部维护虚拟的鼠标指针,在有触摸的时候才更新,如果抬起来的话,第一帧的偏移量特别大,把第一帧return掉
                //return 防止手指抬起之后的第一帧偏移量过大,摄像机会回到默认位置
                return;
            }
            if (Input.GetMouseButtonUp(0))
            {
                isRotating = false;
            }
    
            if(isRotating)
            {
                transform.RotateAround(player. transform.position,Vector3.up,Time.deltaTime* speed * Input.GetAxis("Mouse X"));
    
            }
         
        }
    }
  • 相关阅读:
    achivemq(消息队列)的使用
    java高并发当时处理的思路
    字符串的应用
    正则表达式
    文本文件的读取与写入
    继承
    冒泡排序法
    类与对象
    数据类型
    关键字和语句
  • 原文地址:https://www.cnblogs.com/0315cz/p/8311426.html
Copyright © 2011-2022 走看看