UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Vector3.SmoothDamp
# [Vector3](https://docs.unity3d.com/cn/2019.4/ScriptReference/Vector3.html).SmoothDamp public static [Vector3](https://docs.unity3d.com/cn/2019.4/ScriptReference/Vector3.html) **SmoothDamp** ([Vector3](https://docs.unity3d.com/cn/2019.4/ScriptReference/Vector3.html) **current**, [Vector3](https://docs.unity3d.com/cn/2019.4/ScriptReference/Vector3.html) **target**, ref [Vector3](https://docs.unity3d.com/cn/2019.4/ScriptReference/Vector3.html) **currentVelocity**, float **smoothTime**, float **maxSpeed**= Mathf.Infinity, float **deltaTime**= Time.deltaTime); ## 参数 | current | 当前位置。 | | ----------------- | ----------------------------------------------------------- | | target | 尝试达到的目标。 | | currentVelocity | 当前速度,此值由函数在每次调用时进行修改。 | | smoothTime | 达到目标所需的近似时间。值越小,达到目标的速度越快。 | | maxSpeed | 可以选择允许限制最大速度。 | | deltaTime | 自上次调用此函数以来的时间。默认情况下为 Time.deltaTime。 | ## 描述 随时间推移将一个向量逐渐改变为所需目标。 向量通过某个类似于弹簧-阻尼的函数(它从不超过目标)进行平滑。 最常见的用法是用于平滑跟随摄像机。 ``` // Smooth towards the target using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public Transform target; public float smoothTime = 0.3F; private Vector3 velocity = Vector3.zero; void Update() { // Define a target position above and behind the target transform Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10)); // Smoothly move the camera towards that target position transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime); } } ```
da
2022年6月22日 10:59
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码