Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Vector3.SmoothDamp 平滑阻尼
# [Vector3](Vector3.html).SmoothDamp 平滑阻尼 static function *SmoothDamp* (*current* : [Vector3](Vector3.html), *target* : [Vector3](Vector3.html), *ref currentVelocity* : [Vector3](Vector3.html), *smoothTime* : float, *maxSpeed* : float = [Mathf.Infinity](../Mathf/Mathf.Infinity.html), *deltaTime* : float = [Time.deltaTime](../Time/Time.deltaTime.html)) : [Vector3](Vector3.html) ### Parameters**参数** * *current* The current position. 当前的位置 * *target* The position we are trying to reach. 我们试图接近的位置 * *currentVelocity* The current velocity, this value is modified by the function every time you call it. 当前速度,这个值由你每次调用这个函数时被修改 * *smoothTime* Approximately the time it will take to reach the target. A smaller value will reach the target faster. 到达目标的大约时间,较小的值将快速到达目标 * *maxSpeed* Optionally allows you to clamp the maximum speed. 选择允许你限制的最大速度 * *deltaTime* The time since the last call to this function. By default [Time.deltaTime](../Time/Time.deltaTime.html). 自上次调用这个函数的时间。默认为 [Time.deltaTime](../Time/Time.deltaTime.html) *Description* 描述 Gradually changes a vector towards a desired goal over time. 随着时间的推移,逐渐改变一个向量朝向预期的目标。 The vector is smoothed by some spring-damper like function, which will never overshoot. The most common use is for smoothing a follow camera. 向量由一些像弹簧阻尼器函数平滑,这将永远不会超过。最常见的用途是平滑跟随相机。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform target; public float smoothTime = 0.3F; private Vector3 velocity = Vector3.zero; void Update() { Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10)); transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime); } } ``` ``` // Smooth towards the target //平滑朝向目标 var target : Transform; var smoothTime = 0.3; private var velocity = Vector3.zero; function Update () { // Define a target position above and behind the target transform //定义一个目标位置在目标变换的上方并且在后面 var targetPosition : Vector3 = target.TransformPoint(Vector3(0, 5, -10)); // Smoothly move the camera towards that target position //平滑地移动摄像机朝向目标位置 transform.position = Vector3.SmoothDamp(transform.position, targetPosition, velocity, smoothTime); } ```
da
2022年5月23日 21:52
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码