当前位置:网站首页>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);
}
}
边栏推荐
- 蓝桥杯历届试题-高僧斗法(博弈论)
- 【全排列】
- 记一次“粗暴”的Flash模拟EEPROM法(用的STM32F030C6芯片,没找到模拟EEPROM库函数)
- 关于字符串根据字典序排序的方法
- 指南针股票软件股票开户安全嘛
- 移动web开发-布局篇
- 关于MODBUS RTU的T3.5 、T1.5的时序问题
- Light-Head R-CNN 阅读笔记
- Error executing sql file from Mysql Workbench: Error executing task: 'ascii' codec can't decode byte 0xd0 in position 26:
- 将板子芯片从ST32F101改为STM32F103要改的地方
猜你喜欢
随机推荐
C#中构造函数的作用
ES6入门基础知识
如何使用WebDAV?
最新7篇数据科学/深度学习/CNN/知识图谱/文本匹配等中英文综述论文推介(附下载)
Anaconda 使用 Navigator 安装 Tensorflow(包括 Anaconda 安装)
关于如何求两个字符串的最大公共子串的问题
MVC与MVP的区别
杭电多校8 补题
如何下载安装穿越派V3.14版本?
LeetCode 0179. 最大数
穿越派·派盘+KeePass = 最安全的私人密码管理方案
【Full arrangement】
vspm虚拟串口调试
2017年11月历史文章汇总
一种新的测转速的方法
如何使用电脑云盘?
逐片元-兰伯特光照模型
2021.10.7 2020 CCPC重现赛
【 StoneDB Class 】 introductory lesson 3: StoneDB installation of compilation
2017年9月历史文章汇总









