P.S.很多游戏里的Player都会设置的被跟踪,是人性的扭曲,还是XXX,正在解密。

第三人称视角

  1. camera紧跟player背后(角度随player改变)
using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class FollowTarget : MonoBehaviour { private Transform player;
private Vector3 offset;//偏移值
private float smoothing = 3.0f;//平滑度 // Use this for initialization
void Start () {
player = GameObject.FindGameObjectWithTag("Player").transform;
offset = transform.position - player.position;
} // Update is called once per frame
void LateUpdate () {
Vector3 targetPosition = player.position + player.TransformDirection(offset);//局部坐标,跟随背后
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smoothing);
transform.LookAt(player);
}
}

效果如下:(一直保持这个视角)

  1. camera保持一个角度做俯视(像被上帝注视,颤抖吧player!)
using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class FollowTarget : MonoBehaviour { private Transform player;
private Vector3 offset;
private float smoothing = 3.0f;//平滑度 // Use this for initialization
void Start () {
player = GameObject.FindGameObjectWithTag("Player").transform;
offset = transform.position - player.position;
} // Update is called once per frame
void LateUpdate () {
Vector3 targetPosition = player.position + offset;//世界坐标,上帝视角
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smoothing);
transform.LookAt(player);
}
}

效果如下:(可以看到身前)

两个跟踪方式只有一行代码的不同,但是游戏体验效果差很多,自己实现体现被跟踪的乐趣吧。

Player的跟踪狂 -- Camera的更多相关文章

  1. monkey之三:monkey测试测略(摘抄)

    一.分类 Monkey测试针对不同的对象,不同的目的,采用不同的测略方案. 测试类型分为: 应用程序的稳定性测试和压力测试 测试对象分为: 单个APK和多个APK集合 测试目的分为: 解决问题的测试( ...

  2. android 进程间通信---Service Manager(1)

    Bind机制由4个部分组成.bind驱动,Client,ServiceManager &Service 1.Bind其实是一个基于linux系统的驱动,目的是为了实现内存共享. bind驱动的 ...

  3. Android Binder------ServiceManager启动分析

    ServiceManager启动分析   简述: ServiceManager是一个全局的manager.调用了Jni函数,实现addServicew getService checkService ...

  4. Unity3D中的第三人称镜头的脚本控制

    原地址:http://blog.csdn.net/mobanchengshuang/article/details/27591271 好久没有敲Blog了,谢谢大家的留言.关注.私信等支持,但是我好像 ...

  5. Unity 之 Redux 模式(第二篇)—— Rigidbody 改造,摄像机控制

    作者:软件猫 日期:2016年12月8日 转载请注明出处:http://www.cnblogs.com/softcat/p/6144041.html 上一篇文章中存在一个很严重的问题,首先我们先让 M ...

  6. android binder机制之——(创建binder服务)

      Binder机制编程 前面的几篇文章具体介绍了android中binder机制的方方面面,相信你对binder机制已经有了较深刻的理解.俗话说得好"学以致用",以下我们就通过在 ...

  7. Unity3D第三人称摄像机控制脚本

    好久没有敲Blog该.感谢您的留言.注意.私人信件和其他支持,但我似乎没有办法继续自己曾经写了一篇博客系列,因为我在网上找到有关unity3D太少的内容,U3D相关的文章!.. 第三人称视角 第三人称 ...

  8. Android系统服务详解-android学习之旅(95)

    本文是看完android框架揭秘第六章后的总结 android系统服务提供最基本的,最稳定的核心功能,如设备控制,信息通知,通知设定,以及消息显示等,存在于Android Framework与Andr ...

  9. unity3d 角色头顶信息3D&2D遮挡解决方案(二)

    在阅读本文之前请先阅读上一篇文章:http://www.cnblogs.com/shenggege/p/4179012.html 本来一篇文章就可以说完了,但是上次只是实现了已知的一些功能 后来在实际 ...

随机推荐

  1. HDU 6134

    题意略. 思路: 我们先不考虑[(i , j) == 1],在此情况下,其实这个值是sum( [ (i , j) == 1,2,3,....,n ] ) 这些情况.我们要求的仅仅是其中的第一部分而已. ...

  2. 生产环境中Redis的key的设计

    问题:如果我们需要将MySql表的数据存储到Redis中该如何存储? 例如:有t_user表 id username email  11 leo  leo@163.com  22  laymans   ...

  3. liunx安装jdk

    jdk 安装包  https://pan.baidu.com/s/1cKnUQGU2Sk2nsARAzzVAHw [root@localhost ~]# tar -zxvf jdk-8u152-lin ...

  4. C# 生产者与消费者模式

    情景:一个线程不断获取数据,另一个线程不断处理这些数据. 常规方法:数据列表加锁,两个线程获取锁,拿到操作权:类似代码如下:(不推荐) static void Main(string[] args) ...

  5. 运行git提示xcrun: error: invalid active developer path错误

    运行git提示xcrun: error: invalid active developer path错误 是xcode的原因 运行如下命令解决: xcode-select --install

  6. poj2396 Budget 上下界可行流

    Budget:http://poj.org/problem?id=2396 题意: 给定一个棋盘,给定每一行每一列的和,还有每个点的性质.求一个合理的棋盘数值放置方式. 思路: 比较经典的网络流模型, ...

  7. P1603 斯诺登的密码-字符串加法的妙用

    传送门:https://www.luogu.org/problemnew/show/P1603 题意: 首先在给定的字符串中,找出特定的单词,把它转化成特定的数字, 然后在这些数字中,找出排列结果最小 ...

  8. Atcoder E - Meaningful Mean(线段树+思维)

    题目链接:http://arc075.contest.atcoder.jp/tasks/arc075_c 题意:问数组a有多少子区间平均值为k 题解:一开始考虑过dp,但是显然不可行,其实将每一个数都 ...

  9. CF989B A Tide of Riverscape 思维 第七题

    A Tide of Riverscape time limit per test 1 second memory limit per test 256 megabytes input standard ...

  10. html/css中float浮动的用法

    一.float基础用法示例 1.我们先建两个div盒子,设置高度.宽度和背景颜色: 最开始两个盒子在网页上的位置如下: 然后我们将红色盒子浮动到右边 然后我们会发现红色盒子浮动到了右边,但是蓝色盒子就 ...