Mathf.SmoothStep()

作者:追风剑情 发布于:2017-6-9 18:10 分类:Unity3d

public static float SmoothStep(float from, float to, float t);

在from与to之间平滑插值。

示例:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ExampleClass : MonoBehaviour
  5. {
  6. public float minimum = 10.0F;
  7. public float maximum = 20.0F;
  8. public float duration = 5.0F;
  9. private float startTime;
  10. void Start()
  11. {
  12. startTime = Time.time;
  13. }
  14. void Update()
  15. {
  16. float t = (Time.time - startTime) / duration;
  17. transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
  18. }
  19. }

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号