当前位置:网站首页>Unity学习笔记--摄像机插值跟随
Unity学习笔记--摄像机插值跟随
2022-08-09 00:09:00 【秋瞑小雁客】
Unity学习笔记–摄像机插值跟随
让摄像机跟随玩家运动,使用插值跟随可以让效果看起来更平滑,不那么死板`
// Update is called once per frame
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FellowCamera : MonoBehaviour {
private Transform targetPos;
private Vector3 offsetPos;//固定位置
private Vector3 temPos;//临时变量
// Use this for initialization
void Start () {
targetPos=GameObject.FindGameObjectWithTag("Player").transform;//注意要将要跟随的物体标签设置为“player”;
offsetPos = this.transform.position - targetPos.transform.position;
}
void FixedUpdate ()
{
temPos = targetPos.position + targetPos.TransformDirection(offsetPos);
this.transform.position = Vector3.Lerp(transform.position, temPos, Time.fixedDeltaTime*3);//插值跟随,fixedDeltaTime*3,"3"可以调节跟随的效果;
transform.LookAt(targetPos);
}
}
边栏推荐
猜你喜欢
随机推荐
SyntaxError line:3546,column:96577,SyntaxError: Unexpected token '...'. Expected a property name.
卷积神经网络反向传播直观理解
NPM配置阿里下载源
如何使用WebDAV?
半兰伯特光照模型
菲涅尔反射
关于MODBUS RTU的T3.5 、T1.5的时序问题
C——《C和指针》第六章读书笔记
C# ToString
关于如何求两个字符串的最大公共子串的问题
穿越派·派盘V3.14发版啦!
北京信息科技大学第十三届程序设计竞赛暨ACM选拔赛(重现赛)
C--《C和指针》第8章读书笔记之效率问题
远程访问jupyter notebook
穿越派·派盘(WebDAV)解决OmniFocus同步问题
C#一些简单的知识
如何升级穿越派V3.14版本?
微信小程序 【控制台报错-汇总】
gptp协议
Why software development methodology make you feel bad?