国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

一種比較勻速的差值運算

2019-11-06 06:52:04
字體:
供稿:網(wǎng)友
//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/


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 湖南省| 麦盖提县| 安丘市| 新晃| 双桥区| 扬州市| 岐山县| 从江县| 潢川县| 子洲县| 石柱| 嵩明县| 广灵县| 江源县| 忻州市| 鹿泉市| 水城县| 浠水县| 乾安县| 石阡县| 新绛县| 新营市| 靖安县| 思茅市| 双城市| 普宁市| 葵青区| 沛县| 锦州市| 常山县| 苏尼特左旗| 古田县| 双牌县| 松阳县| 车险| 南丹县| 舞阳县| 洱源县| 隆回县| 图木舒克市| 德州市|