
Unity中实现摄像头跟随功能
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本教程详细介绍如何在Unity引擎中编写脚本,使摄像机能够智能地跟踪游戏中的目标对象。适合中级开发者学习。
代码很简单,这里就不多废话了,直接奉上代码:
```csharp
using UnityEngine;
using System.Collections;
public class FllowTarget : MonoBehaviour
{
public Transform character; // 摄像机要跟随的人物
public float smoothTime = 0.01f; // 摄像机平滑移动的时间
private Vector3 cameraVelocity = Vector3.zero;
private Camera mainCamera; // 主摄像机(有时候工程中会有多个摄像机)
}
```
全部评论 (0)
还没有任何评论哟~


