1. public class CameraFollow : MonoBehaviour
  2. {
  3. public Transform target; // The position that that camera will be following.
  4. public float smoothing = 5f; // The speed with which the camera will be following.
  5. Vector3 offset; // The initial offset from the target.
  6.  
  7. void Start ()
  8. {
  9. // Calculate the initial offset.
  10. offset = transform.position - target.position;
  11. }
  12.  
  13. void FixedUpdate ()
  14. {
  15. // Create a postion the camera is aiming for based on the offset from the target.
  16. Vector3 targetCamPos = target.position + offset;
  17.  
  18. // Smoothly interpolate between the camera's current position and it's target position.
  19. transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
  20. }
  21. }

【Unity笔记】摄像机跟随目标角色的更多相关文章

  1. Unity3D中的高级摄像机跟随

    在Unity3D中,先调整MainCamera在场景中的位置,然后把脚本挂到MainCamera上,摄像机跟随分为简单的摄像机跟随和高级摄像机跟随. 简单摄像机跟随: public class Cam ...

  2. 关于Unity中的小案例之运动的小船以及摄像机跟随技术(专题五)

    实例步骤 1.创建Unity项目和文件目录,保存场景 场景搭建 2.导入美术做好的资源包(第68) a: 导入地形资源包terrain.unitypackage,把里面的Map/Prefabs/Ter ...

  3. 【Unity笔记】第三人称相机跟随

    第三人称,摄像机跟在角色后上方. void Update () { myCamera.position = transform.position + , ); myCamera.LookAt(tran ...

  4. Unity相机平滑跟随

    简介 unity中经常会用到固定视角的相机跟随,然后百度发现大家都是自己写的,然后偶也写咯一个,分享一下 PS: 由于刚学C#不久,才发现delegate这个东东,也不知道对性能影响大不大,但是看MS ...

  5. 笔记-mongodb-用户及角色

    笔记-mongodb-用户及角色 1.      users 其实mongodb支持多种验证方式,本文只提及最简单也最常用的方式. 1.1.  Authentication Database When ...

  6. Unity学习笔记_控制人物移动+摄像机跟随

    我想做的移动操作方式类似[流星蝴蝶剑].[龙之谷].[我的世界第三人称]的第三人称操作方式. 操作说明:W键会朝当前镜头方向前进,鼠标控制镜头旋转. 做前需知(先去稍微了解一下比较好): ①unity ...

  7. 【Unity笔记】角色的移动方法

    方法一:改变物体的transform public class ExampleClass : MonoBehaviour { ; // 跟随摄像机的移动要写在LateUpdate中 void Late ...

  8. unity3d 摄像机跟随角色时被物体遮挡解决方案

    参考文章:http://www.xuanyusong.com/archives/1991 在看此文章时请先看上面的参考文章 看完以上文章后,你也许会想人家都已经给出所有代码了,你还写个毛啊 别急,现在 ...

  9. Unity 摄像机跟随

    方式一:将摄像机直接拖到游戏对象的下面: 方式二:脚本实现 using System.Collections; using System.Collections.Generic; using Unit ...

随机推荐

  1. 3DTouch - iOS新特性

    概述 3DTouch是一种立体触控技术,被苹果称为新一代多点触控技术. 详细 代码下载:http://www.demodashi.com/demo/10708.html 6s和6s plus之后特有效 ...

  2. 掀开图片显示介绍的css效果

    概述 主要运用到CSS3的3D transform等变换 详细 代码下载:http://www.demodashi.com/demo/10575.html 一.概述 1.主要运用到CSS3的3D tr ...

  3. springmvc环境搭建及实例

    一. 软件环境 eclipse-jee-mars-R-win32-x86_64 jdk1.7.0_79 apache-tomcat-7.0.52 spring-framework-3.2.0.RELE ...

  4. web服务器一些概念

    一.Web服务器 Web服务基于HTTP协议,HTTP协议基于TCP/IP协议. HTTP请求底层必然是套接字,也就是TCP协议,HTTP服务器就是监听端口的一个守护进程. 它负责HTTP连接的建立. ...

  5. ubuntu修改固定ip

    1.vi /etc/network/interfasces,添加红框内的内容:

  6. CentOS 安装 Hadoop

    原文地址:http://www.cnblogs.com/caca/p/centos_hadoop_install.html 下载和安装   download hadoop from http://ha ...

  7. ulbuntu 安装配置 java

    一.下载JDK        下载地址: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151 ...

  8. JMeter UI 启动时报错

    Problem After running jmeter.bat command under Windows 7 with cmd  the following error is produced:W ...

  9. RMAN兼容性列表

    Target/Auxiliary Database RMAN Executable Catalog Database Catalog Schema 8.1.7.4 8.1.7.4 >=8.1.7 ...

  10. 选择问题 and 字谜游戏问题

    #include <stdio.h> #include <stdlib.h> // 第一题 // 找出N个数的第k个最大者 // 方法1:排序(冒泡),降序找出第k个值 // ...