zoukankan      html  css  js  c++  java
  • [原]unity3D 相机跟随

    using UnityEngine;
    using System.Collections;

    public class CameraFollow : MonoBehaviour {
        
            public Transform target;
            private Vector3 wantedPosition;
        
            private float currentX;
            private float currentY;
            private float currentZ;
        
            private float xVelocity = 0.0F;
            private float yVelocity = 0.0F;
            private float zVelocity = 0.0f;
            private float distanceSnapTime = 0.1f;
        
        // Update is called once per frame
        void Update () {
        
                Vector3 targetPos = target.position;
                
                wantedPosition.x =  targetPos.x;
                
                wantedPosition.z = targetPos.z - 5f;//Vector3.forward*distance;   
                
                wantedPosition.y = targetPos.y -2f;// + heightAbovePlayer;
                
                currentX = Mathf.SmoothDamp(currentX, wantedPosition.x, ref xVelocity, distanceSnapTime);
                
                currentY = Mathf.SmoothDamp(currentY, wantedPosition.y, ref yVelocity, distanceSnapTime);
                
                currentZ = Mathf.SmoothDamp(currentZ, wantedPosition.z, ref zVelocity, 0.5f);
                
                transform.position = new Vector3(currentX,currentY,currentZ);
                transform.LookAt(transform.position + new Vector3(0f,0.95f,1));
        }
    }

  • 相关阅读:
    事务与事务隔离级别
    TNS12535: TNS: 操作超时
    11g的exp导出空表提示EXP00011: SCOTT.TEST1 不存在
    oracle中chr含义
    SQL Server 2008 System Views Map
    SQL Server Execution Plans eBook
    生成建表脚本(V3.0)
    SQL Server 2008 通过配置数据库邮件实现发送邮件功能
    MSSQL2005中的非公开存储过程sp_msdependencies
    SQL Server Tacklebox Free eBook
  • 原文地址:https://www.cnblogs.com/U-tansuo/p/CameraFollow.html
Copyright © 2011-2022 走看看