一种比较匀速的差值运算
来源:互联网 发布:a星寻路算法介绍 编辑:程序博客网 时间:2024/05/01 14:09
//x0 is the follower's old position, y0 is the target's old position, yt is the target's new position, t is the elapsed time, and k is the lerp rate, as in (1 - Mathf.Exp(-k * Time.deltaTime)) before. You used 20 for that. The return value is the follower's new position. So you call it much like Vector3.Lerp, except you pass the target's old and new positions, rather than just its new position. //The maths assumes that the target is moving with constant velocity over the time slice, so if the target is changing velocity rapidly as well it's still going to jitter a bit. But in any case it should be a lot more smooth than plain Lerp was, and other than being smooth, it has exactly the same behaviour (e.g. response to different k values, following distance, etc). Vector3 SuperSmoothLerp(Vector3 x0, Vector3 y0, Vector3 yt, float t, float k) { Vector3 f = x0 - y0 + (yt - y0) / (k * t); //Debug.Log("差值是:" + Mathf.Exp(-k * t).ToString()); return yt - (yt - y0) / (k * t) + f * Mathf.Exp(-k * t); }transform.position = SuperSmoothLerp(transform.position, oldWantTo, to, cameraSpeed, Time.deltaTime); oldWantTo = transform.position;
float lerp = 1f - Mathf.Exp(-cameraRotSpeed * Time.deltaTime); transform.rotation = Quaternion.Lerp(transform.rotation, nowQu, lerp);
来自:https://forum.unity3d.com/threads/how-to-smooth-damp-towards-a-moving-target-without-causing-jitter-in-the-movement.130920/
0 0
- 一种比较匀速的差值运算
- 时间差值的运算 VARIANT的使用
- java比较两个时间的差值
- 匀速的世界
- 一种比较大小的写法
- mysql的比较运算
- Ruby的比较运算
- 比较字符串,然后求差值
- js时间比较与差值
- 日期差值——一种快速的求解方法(Hash的思想)
- 关于关系运算的一种简短描述
- 一种经典位运算的规则
- 美化过的匀速图片滚动
- 贝塞尔曲线 --匀速贝塞尔曲线运动的实现
- 匀速贝塞尔曲线运动的实现(转)
- 如何做一个匀速旋转的轮子
- 美化过的匀速图片滚动
- 比较运算符的重载
- 如何在github上传自己的项目
- 【POJ1474】监控摄像头 半平面交
- jQuery的属性与样式之切换样式.toggleClass()
- java死锁
- 密码脱落
- 一种比较匀速的差值运算
- 49. Group Anagrams
- 判断手机音量大小,做出提醒
- PTA 5-8 哈利波特的考试 (Java实现)
- <Android开源库> Realm For Android~ Queries(译文)
- 移动端如何禁止body的滚动
- ajax跨域
- 基于opencv的bp神经网络判别
- 欢迎使用CSDN-markdown编辑器