当前位置:网站首页>Unity_平滑移动
Unity_平滑移动
2022-08-09 19:20:00 【不可_收_圾】
/*用场景中target物体位置为基准进行偏移后的位置作为位移目标点位置*/
public Transform target;
public float smoothTime = 0.75F;//移动花费的时间,越小速度越快
private Vector3 velocity = Vector3.zero;
void Start()
{
}
void Update()
{
Vector3 targetPosition = target.TransformPoint(new Vector3(0, 0, -10));//在target物体位置基础上把Z轴偏移-10距离的位置点
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
/*velocity为当前速度,此值由函数在每次调用时进行修改*/
}
边栏推荐
猜你喜欢
随机推荐
DSPE-PEG-PDP,DSPE-PEG-OPSS,磷脂-聚乙二醇-巯基吡啶可减少肽的免疫原性
痛击面试官 CURD系统也能做出技术含量
Toronto Research Chemicals单羟基舒更葡糖钠说明书
『百日百题 · 基础篇』备战面试,坚持刷题 第五话——循环语句(2)!
【NOI模拟赛】防AK题(生成函数,单位根,Pollard-Rho)
hdu 2647 Reward(拓扑排序)
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰二氧化硅颗粒用
LeetCode Daily Question (321. Create Maximum Number)
AttributeError: module 'click' has no attribute 'get_os_args'
[Free column] APK dynamic reverse application of Android security [Three Smali injection methods]
Js查找字符串中出现最多次数的字母和单词
安科瑞支持以太网通讯、profibus通讯嵌入式电能表APM指导性技术要求-Susie 周
【二叉树】树的子结构
win10配置CenterNet环境
C语言之实现倒置字符串的两种方法
继承关系下构造方法的访问特点
嵌入式开发:使用FILL提高代码完整性
一种基于连接和安全熵的网络空间整体安全认识和方法
Reverse Analysis of Unknown Cryptographic Protocol Based on Network Data Flow
Prometheus Operator 自定义监控添加redis explorer