###### alayeshi的专栏

Unity的世界我曾来过，程序的世界很单纯！

###### unity3d相机跟随物体平滑移动（C#代码）
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));
}
}

#### 【Unity】 相机移动脚本

2016-01-27 16:32:28

#### Unity摄像机 向指定位置移动旋转 C#脚本

2016-05-21 20:45:05

#### Unity中SmoothDamp 平滑阻尼--相机跟随角色移动的示例

2017-12-12 17:38:20

#### unity 常用的几种相机跟随

2016-06-01 11:37:50

#### unity之--相机跟随移动

2017-12-03 20:55:46

#### Unity3D学习笔记之一：相机缓动跟随

2016-11-25 22:31:04

#### unity 如何控制摄像机跟随角色移动

2016-09-09 23:06:35

#### Unity 控制摄像机跟随运动物体

2016-04-13 11:28:18

#### unity3d摄像机跟随物体移动的简单方法

2015-11-30 00:14:41

#### Unity3D中摄像机跟随方法

2017-01-05 19:37:58

## 不良信息举报

unity3d相机跟随物体平滑移动（C#代码）