当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
随机推荐
2017年8月历史文章汇总
ReflectCubeMap
有人负责,才有质量:写给在集市中迷失的一代
JS基础-数组
Anaconda 使用 Navigator 安装 Tensorflow(包括 Anaconda 安装)
[深度学习] - 网络模型训练过程的 loss 变化分析 (loss / val_loss / test_loss)
微信小程序 【控制台报错-汇总】
在子组件中使用echart视图不刷新的问题
SyntaxError line:3546,column:96577,SyntaxError: Unexpected token '...'. Expected a property name.
VsCode configures your favorite fonts and backgrounds. Mom no longer worries about my boring code writing.
凹凸映射Bump_Mapping
NOR flash和NAND flash的区别
Win10安装 pycocotools
C#中的&、&&、|、||的区别
ADXL345调试心得
穿越派·派盘(WebDAV)解决OmniFocus同步问题
判断输入的信息是否为空,如果为空,提示信息
Several ways to implement inheritance in js
mysql建表常用sql语句
小程序textarea完美填坑